blast-models/macros/utils.sql
drethereum 5d9186eb4b
AN-4520/streamline-udfs-testnet (#4)
* streamline udfs

* udfs

* streamline models

* streamline models

* exploded key

* create udfs edit

* txn history

* testnet sources

* edits

* utils

* livequery for chainhead

* CTE

* secret name path

* udfs

* coalesce

* chainhead table

* tbl config

* request syntax

* core views

* mint precise

* request structure

* Temp changes

* new request structure

* id

* traces structure

* traces history

* partition key

* confirm blocks

* workflows

* tests and observ

* ephit

---------

Co-authored-by: Ryan-Loofy <63126328+Ryan-Loofy@users.noreply.github.com>
2024-02-22 12:11:05 -07:00

79 lines
1.7 KiB
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 %}
{% macro if_data_call_wait() %}
{% if var(
"STREAMLINE_INVOKE_STREAMS"
) %}
{% set query %}
SELECT
1
WHERE
EXISTS(
SELECT
1
FROM
{{ model.schema ~ "." ~ model.alias }}
LIMIT
1
) {% endset %}
{% if execute %}
{% set results = run_query(
query
) %}
{% if results %}
{{ log(
"Waiting...",
info = True
) }}
{% set wait_query %}
SELECT
system$wait(
{{ var(
"WAIT",
600
) }}
) {% endset %}
{% do run_query(wait_query) %}
{% else %}
SELECT
NULL;
{% endif %}
{% endif %}
{% endif %}
{% endmacro %}