diff --git a/macros/streamline/utils.sql b/macros/streamline/utils.sql index f67b6dd..94a6267 100644 --- a/macros/streamline/utils.sql +++ b/macros/streamline/utils.sql @@ -82,3 +82,40 @@ ) }} {%- endif %} {% endmacro %} + +{% macro if_data_call_function_v2( + func, + target, + params + ) %} + {% if var( + "STREAMLINE_INVOKE_STREAMS" + ) %} + {% if execute %} + {{ log( + "Running macro `if_data_call_function`: Calling udf " ~ func ~ " with params: \n" ~ params | tojson(indent=2) ~ "\n on " ~ target, + True + ) }} + {% endif %} + SELECT + {{ this.schema }}.{{ func }}( parse_json($${{ params | tojson }}$$) ) + WHERE + EXISTS( + SELECT + 1 + FROM + {{ target }} + LIMIT + 1 + ) + {% else %} + {% if execute %} + {{ log( + "Running macro `if_data_call_function`: NOOP", + False + ) }} + {% endif %} + SELECT + NULL + {% endif %} +{% endmacro %} \ No newline at end of file