flow-models/macros/api_udf/check_table_exists.sql
WHYTEWYLL 9dae9f240f
Pipeline metadata (#238)
* add: if condition

* removed row_list

* add:  gold view, fix macro, and silver models

* gold view extension

* add: test bronce

* g

* adding test

* add: test

* add: working test

* delete: tags

* delete: hardcode ref
2023-12-04 07:16:32 -08:00

19 lines
473 B
SQL

-- macros/check_table_exists.sql
{% macro check_table_exists(schema_name, table_name) %}
{% set query %}
SELECT count(*)
FROM information_schema.tables
WHERE table_schema = '{{ schema_name }}'
AND table_name = '{{ table_name }}'
{% endset %}
{% set results = run_query(query) %}
{% if execute %}
{% if results and results.rows[0][0] > 0 %}
"True"
{% else %}
"False"
{% endif %}
{% endif %}
{% endmacro %}