Skip to content

Commit 86efa88

Browse files
authored
Append model.batch.id to suffix in make_temp_relation when present (#361)
1 parent 6c41bed commit 86efa88

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

dbt/include/global_project/macros/adapters/relation.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
{% endmacro %}
88

99
{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}
10+
{#-- This ensures microbatch batches get unique temp relations to avoid clobbering --#}
11+
{% if suffix == '__dbt_tmp' and model.batch %}
12+
{% set suffix = suffix ~ '_' ~ model.batch.id %}
13+
{% endif %}
14+
1015
{{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}
1116
{% endmacro %}
1217

0 commit comments

Comments
 (0)