From ae15af6dbe77ac30f8336ec35201dfa7719f8dd8 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 26 Sep 2024 00:27:33 +0100 Subject: [PATCH] optimization: use view for temp relation for microbatch --- .../snowflake/macros/materializations/incremental.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index 9172c061e..ae5a3e0de 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -20,7 +20,7 @@ The append strategy can use a view because it will run a single INSERT statement. - When unique_key is none, the delete+insert strategy can use a view beacuse a + When unique_key is none, the delete+insert and microbatch strategies can use a view beacuse a single INSERT statement is run with no DELETES as part of the statement. Otherwise, play it safe by using a temporary table. #} */ @@ -32,10 +32,10 @@ ) %} {% endif %} - {% if strategy == "delete+insert" and tmp_relation_type is not none and tmp_relation_type != "table" and unique_key is not none %} + {% if strategy in ["delete+insert", "microbatch"] and tmp_relation_type is not none and tmp_relation_type != "table" and unique_key is not none %} {% do exceptions.raise_compiler_error( "In order to maintain consistent results when `unique_key` is not none, - the `delete+insert` strategy only supports `table` for `tmp_relation_type` but " + the `" ~ strategy ~ "` strategy only supports `table` for `tmp_relation_type` but " ~ tmp_relation_type ~ " was specified." ) %} @@ -49,7 +49,7 @@ {{ return("view") }} {% elif strategy in ("default", "merge", "append") %} {{ return("view") }} - {% elif strategy == "delete+insert" and unique_key is none %} + {% elif strategy in ["delete+insert", "microbatch"] and unique_key is none %} {{ return("view") }} {% else %} {{ return("table") }}