Below is an example model to illustrate this structure:
{{ config(materialized=’incremental’) }}
{%- set yaml_metadata -%} hashkey: ‘hk_account_h’ business_keys: - account_key - account_number source_models: stage_account {%- endset -%}
{%- set metadata_dict = fromyaml(yaml_metadata) -%}
{{ datavault4dbt.hub(hashkey=metadata_dict.get(‘hashkey’), business_keys=metadata_dict.get(‘business_keys’), source_models=metadata_dict.get(‘source_models’) ) }}
This example consists of the following parts:
1. DBT Configuration: • {{ config(materialized=’incremental’) }} : Sets the materialization type to incremental, meaning that the table will be updated incrementally rather than being rebuilt from scratch each time 2. Metadata Definition: • The yaml_metadata block contains the definition of the hash key, business keys, and source models in YAML syntax. This metadata must be written correctly to ensure accurate parsing and SQL generation
DATAVAULT4DBT: A COMPREHENSIVE GUIDE © SCALEFREE INTERNATIONAL GMBH 2025
13/18
Powered by FlippingBook