diff --git a/macros/datashares.sql b/macros/datashares.sql index 2a1ef7b..29f663c 100644 --- a/macros/datashares.sql +++ b/macros/datashares.sql @@ -158,3 +158,17 @@ {{- "BEGIN\n" ~ (combined_ddl | join("\n")) ~ "\nEND" -}} {%- endmacro -%} +{% macro get_exclusion_schema() %} +{# + Return a list of schemas to exclude from the data shares + #} +{% set schema = {} %} +{% for key, value in graph.nodes.items() -%} + {% + if key.startswith("test.") or value.schema.startswith("_") + -%} + {% do schema.update({value.schema:None}) %} + {%- endif %} +{%- endfor %} +{{- schema.keys() | list | tojson -}} +{%- endmacro -%} \ No newline at end of file diff --git a/models/datashare/_datashare___create_gold.sql b/models/datashare/_datashare___create_gold.sql index 8439f58..e9cb50f 100644 --- a/models/datashare/_datashare___create_gold.sql +++ b/models/datashare/_datashare___create_gold.sql @@ -10,11 +10,13 @@ SELECT $${{- fsc_utils.generate_datashare_ddl() -}}$$ AS ddl, md5(ddl) AS ddl_hash, -sysdate() as ddl_created_at +sysdate() as ddl_created_at, +{{ fsc_utils.get_exclusion_schema().replace('"',"'") }} as exclusion_schema {% else %} SELECT null as ddl, null as ddl_hash, -null as ddl_created_at +null as ddl_created_at, +null as exclusion_schema from dual limit 0 {% endif %} \ No newline at end of file