[# Reference Hub Template #]
[# Generates a reference hub model using datavault4dbt.ref_hub() macro #]
{{ config(
    materialized='incremental',
    tags=['hub', 'reference', 'raw_vault'[% if group %], '[[ group ]]'[% endif %]]
) }}

{%- set yaml_metadata -%}
source_models:
[% for source in source_tables %]
    - name: [[ source.stage_name ]]
[% if source.rsrc_static %]
      rsrc_static: '[[ source.rsrc_static ]]'
[% endif %]
[% if source.business_key_columns %]
      ref_keys: 
    [% for rk in source.business_key_columns %]
        - [[ rk ]]
    [% endfor %]
[% endif %]
[% endfor %]
ref_keys:
[% for rk in reference_key_columns %]
    - [[ rk ]]
[% endfor %]
{%- endset -%}

{{ datavault4dbt.ref_hub(yaml_metadata=yaml_metadata) }}
