@@ -12,6 +12,7 @@ def create_airflow_dependency(table, partition_column, additional_partitions=Non
12
12
Args:
13
13
table: The table name (with namespace)
14
14
partition_column: The partition column to use (defaults to 'ds')
15
+ additional_partitions: Additional partitions to include in the dependency
15
16
16
17
Returns:
17
18
A dictionary with name and spec for the Airflow dependency
@@ -47,6 +48,12 @@ def _get_partition_col_from_query(query):
47
48
return query .partitionColumn
48
49
return None
49
50
51
+ def _get_additional_subPartitionsToWaitFor_from_query (query ):
52
+ """Gets additional subPartitionsToWaitFor from query if available"""
53
+ if query :
54
+ return query .subPartitionsToWaitFor
55
+ return None
56
+
50
57
51
58
def _get_airflow_deps_from_source (source , partition_column = None ):
52
59
"""
@@ -60,20 +67,22 @@ def _get_airflow_deps_from_source(source, partition_column=None):
60
67
A list of Airflow dependency objects
61
68
"""
62
69
tables = []
70
+ additional_partitions = None
63
71
# Assumes source has already been normalized
64
72
if source .events :
65
73
tables = [source .events .table ]
66
74
# Use partition column from query if available, otherwise use the provided one
67
- source_partition_column = (
68
- _get_partition_col_from_query (source .events .query ) or partition_column
75
+ source_partition_column , additional_partitions = (
76
+ _get_partition_col_from_query (source .events .query ) or partition_column , _get_additional_subPartitionsToWaitFor_from_query ( source . events . query )
69
77
)
78
+
70
79
elif source .entities :
71
80
# Given the setup of Query, we currently mandate the same partition column for snapshot and mutations tables
72
81
tables = [source .entities .snapshotTable ]
73
82
if source .entities .mutationTable :
74
83
tables .append (source .entities .mutationTable )
75
- source_partition_column = (
76
- _get_partition_col_from_query (source .entities .query ) or partition_column
84
+ source_partition_column , additional_partitions = (
85
+ _get_partition_col_from_query (source .entities .query ) or partition_column , _get_additional_subPartitionsToWaitFor_from_query ( source . entities . query )
77
86
)
78
87
elif source .joinSource :
79
88
# TODO: Handle joinSource -- it doesn't work right now because the metadata isn't set on joinSource at this point
@@ -83,7 +92,7 @@ def _get_airflow_deps_from_source(source, partition_column=None):
83
92
return []
84
93
85
94
return [
86
- create_airflow_dependency (table , source_partition_column ) for table in tables
95
+ create_airflow_dependency (table , source_partition_column , additional_partitions ) for table in tables
87
96
]
88
97
89
98
0 commit comments