diff --git a/dbt/include/snowflake/macros/materializations/table.sql b/dbt/include/snowflake/macros/materializations/table.sql index ef201c705..c15336acc 100644 --- a/dbt/include/snowflake/macros/materializations/table.sql +++ b/dbt/include/snowflake/macros/materializations/table.sql @@ -16,7 +16,7 @@ {#-- Drop the relation if it was a view to "convert" it in a table. This may lead to -- downtime, but it should be a relatively infrequent occurrence #} - {% if old_relation is not none and not old_relation.is_table %} + {% if old_relation is not none %} {{ log("Dropping relation " ~ old_relation ~ " because it is of type " ~ old_relation.type) }} {{ drop_relation_if_exists(old_relation) }} {% endif %} diff --git a/dbt/include/snowflake/macros/relations/table/create.sql b/dbt/include/snowflake/macros/relations/table/create.sql index c6bc8f775..42f60392c 100644 --- a/dbt/include/snowflake/macros/relations/table/create.sql +++ b/dbt/include/snowflake/macros/relations/table/create.sql @@ -1,10 +1,17 @@ {% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%} + {{ log('XXX: am i here?', info=True) }} {%- set transient = config.get('transient', default=true) -%} + {%- set iceberg = config.get('iceberg', default=true) -%} + {%- set catalog = config.get('catalog') -%} + {%- set external_volume = config.get('external_volume') -%} + {%- set base_location = config.get('base_location') -%} {% if temporary -%} {%- set table_type = "temporary" -%} - {%- elif transient -%} - {%- set table_type = "transient" -%} + {# {%- elif transient -%} + {%- set table_type = "transient" -%} #} + {%- elif iceberg -%} + {%- set table_type = "iceberg" -%} {%- else -%} {%- set table_type = "" -%} {%- endif %} @@ -33,6 +40,11 @@ {{ get_table_columns_and_constraints() }} {% set compiled_code = get_select_subquery(compiled_code) %} {% endif %} + {% if iceberg and catalog and external_volume %} + CATALOG="{{ catalog }}", + EXTERNAL_VOLUME="{{ external_volume }}", + BASE_LOCATION="{{ base_location }}" + {% endif %} {% if copy_grants and not temporary -%} copy grants {%- endif %} as ( {%- if cluster_by_string is not none -%}