ScalefreeCOM / datavault4dbt

Scalefree's dbt package for a Data Vault 2.0 implementation congruent to the original Data Vault 2.0 definition by Dan Linstedt including the Staging Area, DV2.0 main entities, PITs and Snapshot Tables.
https://www.scalefree.com/
Apache License 2.0
136 stars 25 forks source link

[BUG] redshift__ref_hub: 'str object' has no attribute 'update' #247

Closed maxmue closed 1 month ago

maxmue commented 1 month ago

Describe the bug

I'm building a reference hub and it doesn't compile.

Source:

{{ config(materialized="incremental") }}

{%- set yaml_metadata -%}
source_models:
  - stg_clinsight_euw1_indication
ref_keys: translation_key
{%- endset -%}

{% set metadata_dict = fromyaml(yaml_metadata) %}

{{
    datavault4dbt.ref_hub(
        source_models=metadata_dict.get("source_models"),
        ref_keys=metadata_dict.get("ref_keys"),
    )
}}
Error:

Compilation Error in model indication_rh (models/core/indication_rh.sql)
  'str object' has no attribute 'update'

  > in macro redshift__ref_hub (macros/tables/redshift/ref_hub.sql)
  > called by macro ref_hub (macros/tables/ref_hub.sql)
  > called by model indication_rh (models/core/indication_rh.sql)

Environment

To Reproduce

Please provide:

  1. Your model's SQL
  2. Your compiled model's SQL
  3. The dbt error message
  4. Relevant logs

Expected behavior

It should compile.

tkirschke commented 1 month ago

HI @maxmue and thanks for reaching out!

Could you try changing your model to:

{{ config(materialized="incremental") }}

{%- set yaml_metadata -%}
source_models: stg_clinsight_euw1_indication
ref_keys: translation_key
{%- endset -%}

{% set metadata_dict = fromyaml(yaml_metadata) %}

{{
    datavault4dbt.ref_hub(
        source_models=metadata_dict.get("source_models"),
        ref_keys=metadata_dict.get("ref_keys"),
    )
}}
maxmue commented 1 month ago

Hey @tkirschke, with your suggestion, it works. However, this will be a multi-source hub in the next step, so I kinda need this list-ish input.

tkirschke commented 1 month ago

Hi @maxmue ,

Alright, then please try the syntax as mentioned here.

Your example would look like this then :

{{ config(materialized="incremental") }}

{%- set yaml_metadata -%}
source_models: 
  - name: stg_clinsight_euw1_indication
ref_keys: translation_key
{%- endset -%}

{% set metadata_dict = fromyaml(yaml_metadata) %}

{{
    datavault4dbt.ref_hub(
        source_models=metadata_dict.get("source_models"),
        ref_keys=metadata_dict.get("ref_keys"),
    )
}}
maxmue commented 1 month ago

Thanks! ❤️ Looking forward to our call next week, btw.