cosmos-models/macros/streamline/sp_get_blocks_realtime.sql
Ryan-Loofy 3bfdba7ebf
Initial commit for Cosmos DBT Project (#1)
* Initial commit for Cosmos DBT Project

* Add gitignore

* Removed dbt packages

* Removed dbt logs

* Delete target

* Remove DS_Stores

* Delete ds_store
2022-11-09 09:19:00 -05:00

27 lines
560 B
PL/PgSQL

{% macro create_sp_get_blocks_realtime() %}
{% set sql %}
CREATE
OR REPLACE PROCEDURE streamline.sp_get_blocks_realtime() returns variant LANGUAGE SQL AS $$
DECLARE
RESULT variant;
row_cnt INTEGER;
BEGIN
row_cnt:= (
SELECT
COUNT(1)
FROM
{{ ref('streamline__blocks_realtime') }}
);
if (
row_cnt > 0
) THEN RESULT:= (
SELECT
streamline.udf_get_blocks()
);
ELSE RESULT:= NULL;
END if;
RETURN RESULT;
END;$$ {% endset %}
{% do run_query(sql) %}
{% endmacro %}