polygon-models/macros/utils.sql
cantjaso 9565d67c4d
Jason/blocks (#36)
* Models for blocks stream

* add the utils for post_hook

* add the bronze streamline schema

* Update

* Update

* Duplicate bug fix

* Chainhead route fix

Co-authored-by: yulike <xiuyangguan@gmail.com>
2022-10-31 13:03:52 -04:00

36 lines
759 B
SQL

{% macro if_data_call_function(
func,
target
) %}
{% if var(
"STREAMLINE_INVOKE_STREAMS"
) %}
{% if execute %}
{{ log(
"Running macro `if_data_call_function`: Calling udf " ~ func ~ " on " ~ target,
True
) }}
{% endif %}
SELECT
{{ func }}
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 %}