Skip to content

Commit

Permalink
(closes #1455) Qualify Snowflake temp tables with a database and schema
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin committed May 13, 2019
1 parent 8d74550 commit 90abc2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 1 addition & 5 deletions plugins/snowflake/dbt/include/snowflake/macros/adapters.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{% macro snowflake__create_table_as(temporary, relation, sql) -%}
{% if temporary %}
use schema {{ adapter.quote_as_configured(schema, 'schema') }};
{% endif %}

{%- set transient = config.get('transient', default=true) -%}

create or replace {% if temporary -%}
temporary
{%- elif transient -%}
transient
{%- endif %} table {{ relation.include(database=(not temporary), schema=(not temporary)) }}
{%- endif %} table {{ relation }}
as (
{{ sql }}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
{%- set identifier = model['alias'] -%}

{%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}
{%- set target_relation = api.Relation.create(database=database, identifier=identifier, schema=schema, type='table') -%}
{%- set tmp_relation = api.Relation.create(identifier=identifier ~ "__dbt_tmp", type='table') -%}
{%- set target_relation = api.Relation.create(database=database,
schema=schema,
identifier=identifier,
type='table') -%}

{%- set tmp_relation = api.Relation.create(database=database,
schema=schema,
identifier=identifier ~ "__dbt_tmp",
type='table') -%}

-- setup
{{ run_hooks(pre_hooks, inside_transaction=False) }}
Expand Down

0 comments on commit 90abc2d

Please sign in to comment.