mirror of
https://github.com/FlipsideCrypto/avalanche-models.git
synced 2026-02-06 13:36:53 +00:00
added project level variable and associated IF statements to on-run-start macros to default UDF/SP updates to False (#30)
This commit is contained in:
parent
db858c5b28
commit
cfa49518ad
10
README.md
10
README.md
@ -35,7 +35,17 @@ avalanche:
|
||||
query_tag: <TAG>
|
||||
```
|
||||
|
||||
### Variables
|
||||
|
||||
To control the creation of UDF or SP macros with dbt run:
|
||||
* UPDATE_UDFS_AND_SPS
|
||||
When True, executes all macros included in the on-run-start hooks within dbt_project.yml on model run as normal
|
||||
When False, none of the on-run-start macros are executed on model run
|
||||
|
||||
Default values are False
|
||||
|
||||
* Usage:
|
||||
dbt run --var '{"UPDATE_UDFS_AND_SPS":True}' -m ...
|
||||
|
||||
### Resources:
|
||||
- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction)
|
||||
|
||||
@ -40,3 +40,4 @@ on-run-start:
|
||||
|
||||
vars:
|
||||
"dbt_date:time_zone": GMT
|
||||
UPDATE_UDFS_AND_SPS: False
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
{% macro create_sps() %}
|
||||
{% if target.database == 'AVALANCHE' %}
|
||||
CREATE schema IF NOT EXISTS _internal;
|
||||
{{ sp_create_prod_clone('_internal') }};
|
||||
{% if var("UPDATE_UDFS_AND_SPS") %}
|
||||
{% if target.database == 'AVALANCHE' %}
|
||||
CREATE schema IF NOT EXISTS _internal;
|
||||
{{ sp_create_prod_clone('_internal') }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
{% macro create_udfs() %}
|
||||
{% set sql %}
|
||||
CREATE schema if NOT EXISTS silver;
|
||||
{{ create_js_hex_to_int() }};
|
||||
{{ create_udf_hex_to_int(
|
||||
schema = "public"
|
||||
) }}
|
||||
{% if var("UPDATE_UDFS_AND_SPS") %}
|
||||
{% set sql %}
|
||||
CREATE schema if NOT EXISTS silver;
|
||||
{{ create_js_hex_to_int() }};
|
||||
{{ create_udf_hex_to_int(
|
||||
schema = "public"
|
||||
) }}
|
||||
|
||||
{% endset %}
|
||||
{% do run_query(sql) %}
|
||||
{% endset %}
|
||||
{% do run_query(sql) %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user