Skip to content

Commit b57f0e0

Browse files
committed
add indexes to incremental materialization; add some notes
1 parent 7dcff86 commit b57f0e0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
;
2222
{%- endmacro %}
2323

24-
{# override this just so we can call sqlite_incremental_upsert #}
24+
{#
25+
the incremental materialization was overhauled in dbt 1.3.0 to make it easier to override
26+
adapter-specific pieces, but it's hard to use it as intended in our case, because it renames
27+
models, which is difficult to handle so we just avoid it
28+
29+
also, we call sqlite_incremental_upsert b/c the syntax for insert differs
30+
#}
2531
{% materialization incremental, adapter='sqlite' -%}
2632
2733
{% set unique_key = config.get('unique_key') %}
@@ -63,6 +69,10 @@
6369

6470
{% do persist_docs(target_relation, model) %}
6571

72+
{% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}
73+
{% do create_indexes(target_relation) %}
74+
{% endif %}
75+
6676
{{ run_hooks(post_hooks, inside_transaction=True) }}
6777

6878
-- `COMMIT` happens here

0 commit comments

Comments
 (0)