Need to pass the value from a DB query in one macro and call this first macro inside another macro to pass the values dynamically.
Trying to read values from a databricks table through macro1 and passing them in source yml creation macro to populate values.
{% do sources_yaml.append(" tables:") %}
{% if table_names is none %}
{% set tables = codegen.get_tables_in_schema(
schema_name, database_name, table_pattern, exclude
) %}
{% else %} {% set tables = table_names %}
{% endif %}
{% for table in tables %}
{% do sources_yaml.append(" - name: " ~ table | lower) %}
{% if include_descriptions %}
{% do sources_yaml.append(' description: ""') %}
{% endif %}
{% if generate_columns %}
{% do sources_yaml.append(" columns:") %}
{% set table_relation = api.Relation.create(
database=database_name, schema=schema_name, identifier=table
) %}
{% set columns = adapter.get_columns_in_relation(table_relation) %}
{% for column in columns %}
{% do sources_yaml.append(" - name: " ~ column.name | lower) %}
{% if include_descriptions %}
{% do sources_yaml.append(' description: ""') %}
{% endif %}
{% if include_samplevalue %}
{%- set tblnm = '{table}' -%}
{%- set colnm = '{column}' -%}
adapter.execute_macro('generate_macro1', table_nm='arg1', column_nm = 'arg2')
{%- do sources_yaml.append(" tag_value: " ~ reqdval ) -%}
{% endif %}
{% endfor %}
{% do sources_yaml.append("") %}
{% endif %}
{% endfor %}
I need to pass values dynamically for arg1,arg2 to invoke the macro1 and read the results for populating the variable ‘reqdval’.