Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding config option for table and incremental materializaions #1313

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@

{{ run_hooks(pre_hooks) }}

{{ bigquery__run_script_headers(config.get('script_headers')) }}

{% if partition_by.copy_partitions is true and strategy != 'insert_overwrite' %} {#-- We can't copy partitions with merge strategy --#}
{% set wrong_strategy_msg -%}
The 'copy_partitions' option requires the 'incremental_strategy' option to be set to 'insert_overwrite'.
Expand Down
2 changes: 2 additions & 0 deletions dbt/include/bigquery/macros/materializations/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

{{ run_hooks(pre_hooks) }}

{{ bigquery__run_script_headers(config.get('script_headers')) }}

{#
We only need to drop this thing if it is not a table.
If it _is_ already a table, then we can overwrite it without downtime
Expand Down
21 changes: 21 additions & 0 deletions dbt/include/bigquery/macros/utils/run_script_headers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% macro bigquery__run_script_headers(script_headers) %}
{%- if script_headers is not none -%}
{%- if script_headers is string -%}
{%- set script_headers = [script_headers] -%}
{%- endif -%}

{%- set formatted_script_headers = [] -%}

{%- for script_header in script_headers -%}
{%- set trimmed_script_header = script_header.strip() -%}
{%- if not trimmed_script_header.endswith(';') -%}
{%- set formatted_script_header = trimmed_script_header ~ ';' -%}
{%- else -%}
{%- set formatted_script_header = trimmed_script_header -%}
{%- endif -%}
{%- do formatted_script_headers.append(formatted_script_header) -%}
{%- endfor -%}

{{ formatted_script_headers | join('\n') }}
{%- endif -%}
{%- endmacro -%}