Skip to content

Commit a5fb205

Browse files
committed
#31: make incremental models with unique_key work
1 parent de3313f commit a5fb205

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

dbt/include/sqlite/macros/materializations/incremental/incremental.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
{%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}
55

66
{%- if unique_key is not none -%}
7+
{% call statement('sqlite_incremental_upsert') -%}
78
delete
89
from {{ target_relation }}
910
where ({{ unique_key }}) in (
1011
select ({{ unique_key }})
1112
from {{ tmp_relation }}
1213
);
14+
{%- endcall %}
1315
{%- endif %}
1416

1517
{# difference here is sqlite doesn't want parens around the select query #}

0 commit comments

Comments
 (0)