Need to strip/format an address field in a customer account. Trying to pass the value of the customer account street column into a dbt/jinja macro to parse
Example query:
with
test as (
SELECT
first_name, last_name,
{{ format_street(customer_account.street) }} as account_street,
city, region, postal_code, country
FROM {{ source(db, table }} customer_account
LIMIT 5
)
Macro example just to log what the street even looks like:
{% macro format_street(row_value) %}
{{ log(row_value, info=true) }}
{% endmacro %}
What I’ve already tried
Trying below line:
{{ format_street('street') }} as account_street
logs the column name into the macro and workable with sql, but I’d need the actual string column value to use with jinja
Trying below line:
{{ format_street('customer_account.street') }} as account_street
logs the literal string “customer_account.street” into the macro and not the column value
Trying without quotations:
{{ format_street(customer_account.street) }} as account_street
throws error “‘customer_account’ is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with “dbt deps”.”
Is there a specific format that I’m missing? I’d just need the column value passed into a macro. Have been super hard to find further information on this. Any help is much appreciated in advance