Skip to content

Commit

Permalink
Append the model.batch.id to the temporary relation suffix when ava…
Browse files Browse the repository at this point in the history
…ilable
  • Loading branch information
QMalcolm committed Dec 4, 2024
1 parent 6c41bed commit ab40b89
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dbt/include/global_project/macros/adapters/relation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
{% endmacro %}

{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}
{#-- This ensures microbatch batches get unique temp relations to avoid clobbering --#}
{% if suffix == '__dbt_tmp' and model.batch %}
{% set suffix = suffix ~ '_' ~ model.batch.id %}
{% endif %}

{{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}
{% endmacro %}

Expand Down

0 comments on commit ab40b89

Please sign in to comment.