Skip to content

Commit 940cf6c

Browse files
authored
Merge pull request #180 from dagster-io/izzy/fix_dbt_partition_bug
fixed bug for non-partitioned dbt assets
2 parents e3932d3 + 8d652ef commit 940cf6c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

hooli-data-eng/hooli_data_eng/defs/dbt/component.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,15 @@ def get_owners(self, dbt_resource_props: Mapping[str, Any]):
123123
def _process_partitioned_dbt_assets(
124124
context: dg.AssetExecutionContext, dbt: DbtCliResource
125125
):
126-
# map partition key range to dbt vars
127-
first_partition, last_partition = context.partition_time_window
128-
dbt_vars = {"min_date": str(first_partition), "max_date": str(last_partition)}
129-
dbt_args = ["build", "--vars", json.dumps(dbt_vars)]
126+
# Check if the asset is partitioned
127+
if context.has_partition_key:
128+
# map partition key range to dbt vars
129+
first_partition, last_partition = context.partition_time_window
130+
dbt_vars = {"min_date": str(first_partition), "max_date": str(last_partition)}
131+
dbt_args = ["build", "--vars", json.dumps(dbt_vars)]
132+
else:
133+
# if not partitioned, use default dbt build command
134+
dbt_args = ["build"]
130135

131136
# Invoke dbt CLI
132137
dbt_cli_task = dbt.cli(dbt_args, context=context)

0 commit comments

Comments
 (0)