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

list object has no attribute keys #28

Open
universe-designer opened this issue Mar 13, 2024 · 0 comments
Open

list object has no attribute keys #28

universe-designer opened this issue Mar 13, 2024 · 0 comments

Comments

@universe-designer
Copy link
Contributor

turbovault4dbt generates this link model CUST_NHL_CUST_NATION_NHLC.sql

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

{%- set yaml_metadata -%}
source_models: 
  stage_customer:
    fk_columns: 
      - 'NATIONKEY_HK'
      - 'CUSTKEY_HK'
    payload:
      - C_NAME
      - C_COMMENT

    rsrc_static: 'Customer'
link_hashkey: HK_CUSTOMER_NATION_L 
foreign_hashkeys: 
  - 'NATIONKEY_HK'
  - 'CUSTKEY_HK'

payload:
    - C_NAME
    - C_COMMENT

{%- endset -%}


{% set metadata_dict = fromyaml(yaml_metadata) %}

{%- set link_hashkey = metadata_dict['link_hashkey'] -%}
{%- set foreign_hashkeys = metadata_dict['foreign_hashkeys'] -%}
{%- set payload = metadata_dict['payload'] -%}
{%- set source_models = metadata_dict['source_models'] -%}

{{ datavault4dbt.nh_link(link_hashkey=metadata_dict.get("link_hashkey"),
                        foreign_hashkeys=metadata_dict.get("foreign_hashkeys"),
                        payload=metadata_dict.get("payload"),
                        source_models=metadata_dict.get("source_models")) }}

dbt run causes the following error:

16:28:26 Compilation Error in model CUST_NHL_CUST_NATION_NHLC (models\raw_vault\CUST_NHL_CUST_NATION_NHLC.sql)
'list object' has no attribute 'keys'

in macro nh_link (macros\tables\nh_link.sql)
called by model CUST_NHL_CUST_NATION_NHLC (models\raw_vault\CUST_NHL_CUST_NATION_NHLC.sql)

If I reduce the code to this. It runs successfully

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

{%- set yaml_metadata -%}
source_models: stage_customer

link_hashkey: HK_CUSTOMER_NATION_L 
foreign_hashkeys: 
  - 'NATIONKEY_HK'
  - 'CUSTKEY_HK'

payload:
    - C_NAME
    - C_COMMENT

{%- endset -%}


{% set metadata_dict = fromyaml(yaml_metadata) %}

{%- set link_hashkey = metadata_dict['link_hashkey'] -%}
{%- set foreign_hashkeys = metadata_dict['foreign_hashkeys'] -%}
{%- set payload = metadata_dict['payload'] -%}
{%- set source_models = metadata_dict['source_models'] -%}

{{ datavault4dbt.nh_link(link_hashkey=metadata_dict.get("link_hashkey"),
                        foreign_hashkeys=metadata_dict.get("foreign_hashkeys"),
                        payload=metadata_dict.get("payload"),
                        source_models=metadata_dict.get("source_models")) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant