Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions macros/upload_results/begin_transaction.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% macro begin_transaction() -%}

{{ return(adapter.dispatch('begin_transaction', 'dbt_artifacts')()) }}

{%- endmacro %}

{% macro default__begin_transaction() -%}
{%- endmacro %}

{% macro snowflake__begin_transaction() -%}

{% do run_query('begin transaction') %}

{%- endmacro %}

{% macro postgres__begin_transaction() -%}

{% do run_query('begin') %}

{%- endmacro %}

{% macro sqlserver__begin_transaction() -%}

{% do run_query('begin transaction') %}

{%- endmacro %}
26 changes: 26 additions & 0 deletions macros/upload_results/end_transaction.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% macro end_transaction() -%}

{{ return(adapter.dispatch('end_transaction', 'dbt_artifacts')()) }}

{%- endmacro %}

{% macro default__end_transaction() -%}
{%- endmacro %}

{% macro snowflake__end_transaction() -%}

{% do run_query('commit') %}

{%- endmacro %}

{% macro postgres__end_transaction() -%}

{% do run_query('commit') %}

{%- endmacro %}

{% macro sqlserver__end_transaction() -%}

{% do run_query('commit transaction') %}

{%- endmacro %}
5 changes: 5 additions & 0 deletions macros/upload_results/upload_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
{% set upload_limit = 300 if target.type == 'bigquery' else 5000 %}
{% endif %}

{# Wrap the chunked inserts in a transaction, where the dialect supports it #}
{{ dbt_artifacts.begin_transaction() }}

{# Loop through each chunk in turn #}
{% for i in range(0, objects | length, upload_limit) -%}

Expand All @@ -42,6 +45,8 @@
{# Loop the next 'chunk' #}
{% endfor %}

{{ dbt_artifacts.end_transaction() }}

{# Loop the next 'dataset' #}
{% endfor %}

Expand Down
Loading