Skip to content

Commit

Permalink
seed: Add new macro get_csv_sql
Browse files Browse the repository at this point in the history
The implementation of this new macro `get_csv_sql` comes as a suggestion
by @jtcohen6 at
dbt-labs/dbt-snowflake#112 (comment).

The underlying reason is that the `dbt-snowflake` package needs to run
these queries inside a transaction, but with the current implementation,
the fix would require to duplicate the entire default seed
materialization logic in the package.
  • Loading branch information
adamantike committed May 3, 2022
1 parent ed5df34 commit a5f04d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
{% endmacro %}


{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}
{{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}
{% endmacro %}

{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}
{{ create_or_truncate_sql }};
-- dbt seed --
{{ insert_sql }}
{% endmacro %}


{% macro get_binding_char() -%}
{{ adapter.dispatch('get_binding_char', 'dbt')() }}
{%- endmacro %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
{% set sql = load_csv_rows(model, agate_table) %}

{% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}
{{ create_table_sql }};
-- dbt seed --
{{ sql }}
{{ get_csv_sql(create_table_sql, sql) }};
{% endcall %}

{% set target_relation = this.incorporate(type='table') %}
Expand Down

0 comments on commit a5f04d4

Please sign in to comment.