Skip to content

Commit

Permalink
Adap 321/support all on schema change options (#1195)
Browse files Browse the repository at this point in the history
* Add iceberg ddl generation

---------

Co-authored-by: VersusFacit <[email protected]>
  • Loading branch information
VersusFacit and VersusFacit authored Sep 30, 2024
1 parent 5b595fb commit f60c476
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240930-112041.yaml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 4 additions & 4 deletions dbt/include/snowflake/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand All @@ -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 %}
Expand Down Expand Up @@ -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 %}
Expand All @@ -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 %}
Expand Down

0 comments on commit f60c476

Please sign in to comment.