Skip to content

Commit

Permalink
Merge pull request #196 from ScalefreeCOM/hotfix_multi_active_sat_sta…
Browse files Browse the repository at this point in the history
…ge_bigquery

Hotfix multi active sat stage bigquery
  • Loading branch information
tkirschke authored Jul 3, 2024
2 parents 636ae9d + f78c2b2 commit 0417f9d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions macros/staging/bigquery/stage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
{%- set exclude_column_names = hashed_column_names + prejoined_column_names + missing_column_names + ldts_rsrc_input_column_names %}
{%- set source_and_derived_column_names = (all_source_columns + derived_column_names) | unique | list -%}
{%- set all_columns = adapter.get_columns_in_relation( source_relation ) -%}

{%- set columns_without_excluded_columns = [] -%}
{%- set final_columns_to_select = [] -%}

Expand Down Expand Up @@ -341,7 +340,7 @@ derived_columns AS (
{# Generating Hashed Columns (hashkeys and hashdiffs for Hubs/Links/Satellites) #}
{% if datavault4dbt.is_something(multi_active_config) %}

{%- set tmp_ns = namespace(main_hashkey_dict={}, remaining_hashed_columns={}, hashdiff_names=[]) -%}
{%- set tmp_ns = namespace(main_hashkey_dict={}, remaining_hashed_columns={}, hashdiff_names=[], hashdiff_dict={}) -%}

{%- for column in hashed_columns.keys() -%}
{%- if column == multi_active_config['main_hashkey_column'] and not hashed_columns[column].is_hashdiff -%}
Expand All @@ -350,6 +349,7 @@ derived_columns AS (
{%- do tmp_ns.remaining_hashed_columns.update({column: hashed_columns[column]}) -%}
{%- elif hashed_columns[column].is_hashdiff -%}
{%- do tmp_ns.hashdiff_names.append(column) -%}
{%- do tmp_ns.hashdiff_dict.update({column: hashed_columns[column]}) -%}
{%- endif -%}
{%- endfor -%}

Expand All @@ -368,13 +368,14 @@ ma_hashdiff_prep AS (

SELECT

{% set processed_hash_columns = datavault4dbt.process_hash_column_excludes(hashed_columns) -%}
{% set processed_hash_columns = datavault4dbt.process_hash_column_excludes(tmp_ns.hashdiff_dict) -%}

{{ multi_active_config['main_hashkey_column'] }},
{# Generates only all hashdiffs. #}
{{- datavault4dbt.hash_columns(columns=processed_hash_columns, multi_active_key=multi_active_config['multi_active_key'], main_hashkey_column=multi_active_config['main_hashkey_column']) | indent(4) }},
{{ ldts_alias }}

FROM {{ last_cte }}
FROM main_hashkey_generation
GROUP BY {{ multi_active_config['main_hashkey_column'] }}, {{ ldts_alias }}

),
Expand Down

0 comments on commit 0417f9d

Please sign in to comment.