added if_data_call_function_v2

This commit is contained in:
shah 2024-02-16 13:34:11 -08:00
parent 7de10e09cc
commit 766593d13d

View File

@ -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 %}