Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use new batch context varaibles #967

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20241211-145132.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Refactor to use new batch context varaibles
time: 2024-12-11T14:51:32.239224-06:00
custom:
Author: QMalcolm
Issue: "966"
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@
{% do predicates.append(pred) %}
{% endfor %}

{% if not model.config.get("__dbt_internal_microbatch_event_time_start") or not model.config.get("__dbt_internal_microbatch_event_time_end") -%}
{% if not model.batch or (not model.batch.event_time_start or not model.batch.event_time_end) -%}
{% do exceptions.raise_compiler_error('dbt could not compute the start and end timestamps for the running batch') %}
{% endif %}

{#-- Add additional incremental_predicates to filter for batch --#}
{% do predicates.append(model.config.event_time ~ " >= TIMESTAMP '" ~ model.config.__dbt_internal_microbatch_event_time_start ~ "'") %}
{% do predicates.append(model.config.event_time ~ " < TIMESTAMP '" ~ model.config.__dbt_internal_microbatch_event_time_end ~ "'") %}
{% do predicates.append(model.config.event_time ~ " >= TIMESTAMP '" ~ model.batch.event_time_start ~ "'") %}
{% do predicates.append(model.config.event_time ~ " < TIMESTAMP '" ~ model.batch.event_time_end ~ "'") %}
{% do arg_dict.update({'incremental_predicates': predicates}) %}

delete from {{ target }}
Expand Down
Loading