Skip to content

Commit a48b1a6

Browse files
authored
Fix default value to be empty list for dependencies in StagingQuery. (#802)
## Summary Without this fix, `compile` breaks because can't iterate through None ## Checklist - [ ] Added Unit Tests - [ ] Covered by existing CI - [ ] Integration tested - [ ] Documentation update <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Improved the description and type annotation for the dependencies parameter in the relevant function’s documentation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent c877a1e commit a48b1a6

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

api/python/ai/chronon/staging_query.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def StagingQuery(
8585
:param step_days:
8686
The maximum number of days to process at once
8787
:type step_days: int
88+
:param dependencies:
89+
List of dependencies for the StagingQuery. Each dependency can be either a TableDependency object
90+
or a dictionary with 'name' and 'spec' keys.
91+
:type dependencies: List[Union[TableDependency, Dict]]
8892
:return:
8993
A StagingQuery object
9094
"""
@@ -100,23 +104,25 @@ def StagingQuery(
100104
)
101105

102106
airflow_dependencies = []
103-
for d in dependencies:
104-
if isinstance(d, TableDependency):
105-
# Create an Airflow dependency object for the table
106-
airflow_dependency = airflow_helpers.create_airflow_dependency(
107-
d.table,
108-
d.partition_column,
109-
d.additional_partitions,
110-
d.offset,
111-
)
112-
airflow_dependencies.append(airflow_dependency)
113-
elif isinstance(d, dict):
114-
# If it's already a dictionary, just append it
115-
airflow_dependencies.append(d)
116-
else:
117-
raise ValueError(
118-
"Dependencies must be either TableDependency instances or dictionaries."
119-
)
107+
108+
if dependencies:
109+
for d in dependencies:
110+
if isinstance(d, TableDependency):
111+
# Create an Airflow dependency object for the table
112+
airflow_dependency = airflow_helpers.create_airflow_dependency(
113+
d.table,
114+
d.partition_column,
115+
d.additional_partitions,
116+
d.offset,
117+
)
118+
airflow_dependencies.append(airflow_dependency)
119+
elif isinstance(d, dict):
120+
# If it's already a dictionary, just append it
121+
airflow_dependencies.append(d)
122+
else:
123+
raise ValueError(
124+
"Dependencies must be either TableDependency instances or dictionaries."
125+
)
120126

121127
custom_json = json.dumps({AIRFLOW_DEPENDENCIES_KEY: airflow_dependencies})
122128

0 commit comments

Comments
 (0)