Skip to content

Commit

Permalink
Update incremental logic
Browse files Browse the repository at this point in the history
Or else it won't display correctly, ugh
  • Loading branch information
erinkcochran87 committed Mar 5, 2024
1 parent 7e634e6 commit f2f717f
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,10 @@ def incremental_dbt_models(context: AssetExecutionContext, dbt: DbtCliResource):

Finally, we’ll modify the `daily_metrics.sql` file to reflect that dbt knows what partition range is being materialized. Since the partition range is passed in as variables at runtime, the dbt model can access them using the `var` dbt macro.

In `analytics/models/marts/daily_metrics.sql`, update the model's incremental logic to the following:
In `analytics/models/marts/daily_metrics.sql`, update the contents of the model's incremental logic (`% if is_incremental %}`) to the following:

```sql
{% if is_incremental() %}
where date_of_business >= strptime('{{ var('min_date') }}', '%c') and date_of_business < strptime('{{ var('max_date') }}', '%c')
{% endif %}
where date_of_business >= strptime('{{ var('min_date') }}', '%c') and date_of_business < strptime('{{ var('max_date') }}', '%c')
```

Here, we’ve changed the logic to say that we only want to select rows between the `min_date` and the `max_date`. Note that we are turning the variables into timestamps using `strptime` because they’re loaded as strings.
Expand Down

0 comments on commit f2f717f

Please sign in to comment.