Skip to content

Commit

Permalink
Transient needs sophisticated handling based on what user specifies for
Browse files Browse the repository at this point in the history
transient manually.
  • Loading branch information
VersusFacit committed Aug 29, 2024
1 parent 37006ae commit 1887208
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 3 additions & 1 deletion dbt/include/snowflake/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@


{% macro snowflake__show_iceberg_relations(schema_relation) %}
{%- set sql = 'show iceberg tables in ' ~ schema_relation ~ ';' %}
{%- set sql -%}
show iceberg tables in {{ schema_relation }}
{%- endset -%}
{%- set result = run_query(sql) -%}
{%- do return(result) -%}
{% endmacro %}
23 changes: 14 additions & 9 deletions dbt/include/snowflake/macros/relations/table/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,27 @@

{%- set is_iceberg = _is_iceberg_relation() -%}
{%- set is_temporary = temporary -%}
{%- set is_transient = config.get('transient', default=False) -%}

{%- if is_transient and is_iceberg -%}
{{ exceptions.warn("Iceberg format relations cannot be transient. Please remove either the transient or iceberg parameters from %s. If left unmodified, dbt will ignore 'transient'." % this) }}
{%- endif %}
{%- if is_iceberg -%}
{# -- Check if user supplied a transient model config of True. #}
{%- if config.get('transient') == True -%}
{{ exceptions.warn("Iceberg format relations cannot be transient. Please remove either the transient or iceberg parameters from %s. If left unmodified, dbt will ignore 'transient'." % this) }}
{%- endif %}

{%- if is_temporary and is_iceberg -%}
{{ exceptions.warn("Iceberg format relations cannot be temporary. Please remove either the transient or iceberg parameters from %s. If left unmodified, dbt will ignore 'transient'." % this) }}
{%- endif %}
{# -- Check if runtime is trying to create a Temporary Iceberg table. #}
{%- if is_temporary -%}
{{ exceptions.raise_compiler_error("Iceberg format relations cannot be temporary. Temporary is being inserted into an Iceberg format table while materializing %s." % this) }}
{%- endif %}

{%- if is_iceberg -%}
{{ return('iceberg') }}

{%- elif is_temporary -%}
{{ return('temporary') }}
{%- elif is_transient -%}

{# -- Always supply transient on table create DDL unless user specifically sets transient to false. #}
{%- elif config.get('transient', default=true) -%}
{{ return('transient') }}

{%- else -%}
{{ return('') }}
{%- endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def list_relations_without_caching(project) -> List[SnowflakeRelation]:
database=project.database, schema=project.test_schema, identifier=""
)
with get_connection(my_adapter):
relations = my_adapter.list_relations_without_caching(schema)
relations = my_adapter.list_relations_without_caching(schema.path.schema)
return relations

def test_list_relations_without_caching(self, project):
Expand Down

0 comments on commit 1887208

Please sign in to comment.