Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit e75ccd8

Browse files
committed
update schema
1 parent d2c6789 commit e75ccd8

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

dbt/include/bigquery/macros/materializations/incremental.sql

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,27 @@
6969

7070
{% endmacro %}
7171

72+
73+
{% macro generate_temp_schema(base_relation, temp_schema = none) %}
74+
{%- if temp_schema is not none-%}
75+
{%- set temp_relation = base_relation.incorporate(path={
76+
"schema": temp_schema
77+
}) -%}
78+
{%- do create_schema(temp_relation) -%}
79+
{% endif %}
80+
{% endmacro %}
81+
7282
{% materialization incremental, adapter='bigquery', supported_languages=['sql', 'python'] -%}
7383

7484
{%- set unique_key = config.get('unique_key') -%}
75-
{%- set temp_schema = config.get('temp_schema') -%}
85+
{%- set tmp_schema = config.get('tmp_schema') -%}
7686
{%- set full_refresh_mode = (should_full_refresh()) -%}
7787
{%- set language = model['language'] %}
7888

7989
{%- set target_relation = this %}
8090
{%- set existing_relation = load_relation(this) %}
81-
{%- set temp_schema = config.get('temp_schema') -%}
82-
{%- if temp_schema is not none-%}
83-
{%- set temp_relation = this.incorporate(path={
84-
"schema": temp_schema
85-
}) -%}
86-
{%- do create_schema(temp_relation) -%}
87-
{% endif %}
88-
{%- set tmp_relation = make_temp_relation(temp_relation) %}
91+
{%- set tmp_updated_relation = generate_tmp_schema(this, tmp_schema) -%}
92+
{%- set tmp_relation = make_temp_relation(tmp_updated_relation) %}
8993

9094
{#-- Validate early so we don't run SQL if the strategy is invalid --#}
9195
{% set strategy = dbt_bigquery_validate_get_incremental_strategy(config) -%}

0 commit comments

Comments
 (0)