arbitrum-models/macros/utils.sql
Ryan-Loofy e663710c90
An 3213/an 3214/an 3215/arbitrum streamline (#54)
* Arbitrum Streamline

* Update batches and run time

* Update complete models, update actions

* Update .github/workflows/dbt_run_streamline_history.yml

Co-authored-by: Shah Newaz Khan <shahnewazk@gmail.com>

* Update XXX and batching

---------

Co-authored-by: Shah Newaz Khan <shahnewazk@gmail.com>
2023-05-31 15:00:59 -04: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 %}