Skip to content

Commit

Permalink
Merge pull request #320 from fishtown-analytics/fix/insert-by-period-…
Browse files Browse the repository at this point in the history
…0-19

Fix: insert by period for 0.19
  • Loading branch information
Claire Carroll authored Jan 6, 2021
2 parents 3e0e691 + 8e06246 commit 46dbfed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions macros/materializations/insert_by_period_materialization.sql
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@
);
{%- endcall %}
{% set result = load_result('main-' ~ i) %}
{% set rows_inserted = result['response']['rows_affected'] %}
{% if 'response' in result.keys() %} {# added in v0.19.0 #}
{% set rows_inserted = result['response']['rows_affected'] %}
{% else %} {# older versions #}
{% set rows_inserted = result['status'].split(" ")[2] | int %}
{% endif %}

{%- set sum_rows_inserted = loop_vars['sum_rows_inserted'] + rows_inserted -%}
{%- if loop_vars.update({'sum_rows_inserted': sum_rows_inserted}) %} {% endif -%}

Expand All @@ -167,7 +171,7 @@

{%- set status_string = "INSERT " ~ loop_vars['sum_rows_inserted'] -%}

{% call noop_statement(name='main', message=status_string) -%}
{% call noop_statement('main', status_string) -%}
-- no-op
{%- endcall %}

Expand Down
3 changes: 3 additions & 0 deletions run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ if [[ ! -z $3 ]]; then _seeds="--select $3 --full-refresh"; fi

dbt deps --target $1
dbt seed --target $1 $_seeds
if [ $1 == 'redshift' ]; then
dbt run -x -m test_insert_by_period --full-refresh --target redshift
fi
dbt run -x --target $1 $_models
dbt test -x --target $1 $_models

0 comments on commit 46dbfed

Please sign in to comment.