How to build macros in dbt

71 Views Asked by At
{% macro json_extract(json, paths) %}
    CASE
        {% for path in paths.split(',') %}
            WHEN JSON_PARSE({{ json }}), {{ path }} IS NOT NULL
                THEN JSON_PARSE({{ json }}),  {{ path }} 
        {% endfor %}
        ELSE NULL
    END
{% endmacro %}

I'm trying to build a macros in my dbt to extract multiple path so I could invoke the macros in my model. Everything I've tried is not working.

This is the last macros I built which is not working still.

0

There are 0 best solutions below