I have a model defined as shown below. The select statement is being created by the call to the macro. This macro reads the parameters from an environment variable but the name of the environment variable needs to be a parameter to the macro. The materialization macro can read the environment variable from the config.
Current model:
{{-
config(
materialized='incremental_stream',
incremental_strategy='insert',
parameters_yaml_str="SOURCE_FACT_DATA",
source_name='my_source_name',
source_table_name='my_source_table'
)
-}}
{{ dc.build_select_sql(dc.stream_source('my_source_name','my_source_table'),'SOURCE_FACT_DATA') }}
Current macro:
{%- macro build_insert_source_select_sql(source, config_env_var_name) %}
{# config_env_var_name parameter it is set in each model and contains all the configuration for a table #}
{% set parameters_yaml_str = env_var(config_env_var_name) %}
Now I would like to avoid the extra parameter in the call to the macro and to be able to call it with only one parameter. So when I change the macro as shown below the call to config returns an empty string. What I concluded is that macros called from the model do not have access to the config, sounds strange. So I was hoping somebody could please provide some clarity, thanks,
{%- macro build_insert_source_select_sql(source) %}
{# config_env_var_name parameter it is set in each model and contains all the configuration for a table #}
{% set parameters_yaml_str = env_var(config.get('parameters_yaml_str')) %}