From 7259135d68275abcb48b6d9993dfff09a5a1665e Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Wed, 27 Nov 2024 17:18:29 -0500 Subject: [PATCH 1/4] support MicrobatchConcurrency capability --- dbt/adapters/snowflake/impl.py | 1 + dbt/include/snowflake/macros/materializations/incremental.sql | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index ac0d903db..10ad2a8a1 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -77,6 +77,7 @@ class SnowflakeAdapter(SQLAdapter): Capability.TableLastModifiedMetadata: CapabilitySupport(support=Support.Full), Capability.TableLastModifiedMetadataBatch: CapabilitySupport(support=Support.Full), Capability.GetCatalogForSingleRelation: CapabilitySupport(support=Support.Full), + Capability.MicrobatchConcurrency: CapabilitySupport(support=Support.Full), } ) diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index dbb79de02..a3a3c38e5 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -80,7 +80,9 @@ {%- set unique_key = config.get('unique_key') -%} {% set incremental_strategy = config.get('incremental_strategy') or 'default' %} {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %} - {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %} + + {% set tmp_relation_suffix = '__dbt_tmp' if not model.batch else '__dbt_tmp_' ~ model.batch.id %} + {% set tmp_relation = make_temp_relation(this, suffix=tmp_relation_suffix).incorporate(type=tmp_relation_type) %} {% set grant_config = config.get('grants') %} From 53a9010e9af52ad2d415f40b676567bf4d5b208a Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 2 Dec 2024 09:51:44 -0500 Subject: [PATCH 2/4] changelog entry --- .changes/unreleased/Features-20241202-095136.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Features-20241202-095136.yaml diff --git a/.changes/unreleased/Features-20241202-095136.yaml b/.changes/unreleased/Features-20241202-095136.yaml new file mode 100644 index 000000000..973866a6d --- /dev/null +++ b/.changes/unreleased/Features-20241202-095136.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Support MicrobatchConcurrency +time: 2024-12-02T09:51:36.606097-05:00 +custom: + Author: michelleark + Issue: "1260" From 7829b1039309574e46024f9ee6b44f82f47494ee Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 5 Dec 2024 14:16:37 -0500 Subject: [PATCH 3/4] leverage new global make_temp_relation --- dbt/include/snowflake/macros/materializations/incremental.sql | 3 +-- setup.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index a3a3c38e5..ce0273e43 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -81,8 +81,7 @@ {% set incremental_strategy = config.get('incremental_strategy') or 'default' %} {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %} - {% set tmp_relation_suffix = '__dbt_tmp' if not model.batch else '__dbt_tmp_' ~ model.batch.id %} - {% set tmp_relation = make_temp_relation(this, suffix=tmp_relation_suffix).incorporate(type=tmp_relation_type) %} + {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %} {% set grant_config = config.get('grants') %} diff --git a/setup.py b/setup.py index c0716341d..b237182ce 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ def _plugin_version() -> str: include_package_data=True, install_requires=[ "dbt-common>=1.10,<2.0", - "dbt-adapters>=1.7,<2.0", + "dbt-adapters>=1.10.4,<2.0", "snowflake-connector-python[secure-local-storage]~=3.0", # add dbt-core to ensure backwards compatibility of installation, this is not a functional dependency "dbt-core>=1.8.0", From c69b33b6088c6caab8864197535f8e747a2a849c Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 5 Dec 2024 15:04:23 -0500 Subject: [PATCH 4/4] remove empty line --- dbt/include/snowflake/macros/materializations/incremental.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index ce0273e43..dbb79de02 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -80,7 +80,6 @@ {%- set unique_key = config.get('unique_key') -%} {% set incremental_strategy = config.get('incremental_strategy') or 'default' %} {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %} - {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %} {% set grant_config = config.get('grants') %}