Passing a JSON value to a dbt macro

Hi all,

I’m starting out with Macros and created one which looks up a value in a table and returns the value. I’m passing in a Foreign Key ID however this key is stored in JSON. I am utilizing Snowflake as the Data Warehouse and this JSON sits in a Variant data type column.

I’m able to use Snowflakes JSON notation in my models (alias.column_name:exampleA:exampleB ) and this works fine. However, when using this notation to pass the foreign key to the macro, I get the following error:

expected token ‘,’, got ‘:’
line 10
{{ get_device_type(rd.deal_json:device:product:product_type_id) }}

Can anybody help me out, is this a syntax error or is my understanding of macros wrong?

I suspect you want to pass a string to the macro, because jinja is just a big text templating system. Try wrapping the argument in quotes. Either single or double will do.

e.g.
{{ get_device_type('rd.deal_json:device:product:product_type_id') }}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.