From f60c476596ea45f609badc3e9bba06c9397ee5d0 Mon Sep 17 00:00:00 2001 From: Mila Page <67295367+VersusFacit@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:02:42 -0700 Subject: [PATCH] Adap 321/support all on schema change options (#1195) * Add iceberg ddl generation --------- Co-authored-by: VersusFacit --- .changes/unreleased/Features-20240930-112041.yaml | 6 ++++++ dbt/include/snowflake/macros/adapters.sql | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/Features-20240930-112041.yaml diff --git a/.changes/unreleased/Features-20240930-112041.yaml b/.changes/unreleased/Features-20240930-112041.yaml new file mode 100644 index 000000000..1395a8bf7 --- /dev/null +++ b/.changes/unreleased/Features-20240930-112041.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Add support for all on_schema_change incremental model strategies. +time: 2024-09-30T11:20:41.99589-07:00 +custom: + Author: versusfacit + Issue: "321" diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index aa8895819..b60cea0b0 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -195,7 +195,7 @@ {% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%} {% call statement('alter_column_type') %} - alter table {{ relation.render() }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }}; + alter {{ relation.get_ddl_prefix_for_alter() }} table {{ relation.render() }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }}; {% endcall %} {% endmacro %} @@ -216,7 +216,7 @@ {% else -%} {% set relation_type = relation.type %} {% endif %} - alter {{ relation_type }} {{ relation.render() }} alter + alter {{ relation.get_ddl_prefix_for_alter() }} {{ relation_type }} {{ relation.render() }} alter {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %} {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }} {% endfor %} @@ -275,7 +275,7 @@ {% if add_columns %} {% set sql -%} - alter {{ relation_type }} {{ relation.render() }} add column + alter {{ relation.get_ddl_prefix_for_alter() }} {{ relation_type }} {{ relation.render() }} add column {% for column in add_columns %} {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }} {% endfor %} @@ -288,7 +288,7 @@ {% if remove_columns %} {% set sql -%} - alter {{ relation_type }} {{ relation.render() }} drop column + alter {{ relation.get_ddl_prefix_for_alter() }} {{ relation_type }} {{ relation.render() }} drop column {% for column in remove_columns %} {{ column.name }}{{ ',' if not loop.last }} {% endfor %}