Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dynamic table #72

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
{% if execute %}

{% if operation_type == "apply" %}

{% set model_id = model.unique_id | string %}
{% set alias = model.alias %}
{% set alias = model.alias %}
{% set database = model.database %}
{% set schema = model.schema %}
{% set model_resource_type = model.resource_type | string %}

{% if model_resource_type|lower in ["model", "snapshot"] %}

{# This dictionary stores a mapping between materializations in dbt and the objects they will generate in Snowflake #}
{% set materialization_map = {"table": "table", "view": "view", "incremental": "table", "snapshot": "table"} %}
{% set materialization_map = {"table": "table", "view": "view", "incremental": "table", "snapshot": "table", "dynamic_table": "table"} %}

{# Append custom materializations to the list of standard materializations #}
{% do materialization_map.update(fromjson(var('custom_materializations_map', '{}'))) %}
Expand All @@ -23,7 +23,7 @@

{% set masking_policy_db = model.database %}
{% set masking_policy_schema = model.schema %}

{# Override the database and schema name when use_common_masking_policy_db flag is set #}
{%- if (var('use_common_masking_policy_db', 'False')|upper in ['TRUE','YES']) -%}
{% if (var('common_masking_policy_db') and var('common_masking_policy_schema')) %}
Expand All @@ -39,7 +39,7 @@
{% endif %}
{% endif %}

{% set masking_policy_list_sql %}
{% set masking_policy_list_sql %}
show masking policies in {{masking_policy_db}}.{{masking_policy_schema}};
select $3||'.'||$4||'.'||$2 as masking_policy from table(result_scan(last_query_id()));
{% endset %}
Expand All @@ -53,7 +53,7 @@
{% set column = meta_tuple[0] %}
{% set masking_policy_name = meta_tuple[1] %}
{% set conditional_columns = meta_tuple[2] %}

{% if masking_policy_name is not none %}

{% for masking_policy_in_db in masking_policy_list['MASKING_POLICY'] %}
Expand All @@ -72,7 +72,7 @@
{% endfor %}

{% endif %}

{% elif operation_type == "unapply" %}

{% for node in graph.nodes.values() -%}
Expand All @@ -81,7 +81,7 @@
{% set schema = node.schema | string %}
{% set node_unique_id = node.unique_id | string %}
{% set node_resource_type = node.resource_type | string %}
{% set materialization_map = {"table": "table", "view": "view", "incremental": "table", "snapshot": "table"} %}
{% set materialization_map = {"table": "table", "view": "view", "incremental": "table", "snapshot": "table", "dynamic_table": "table"} %}

{% if node_resource_type|lower in ["model", "snapshot"] %}

Expand All @@ -104,7 +104,7 @@
{% endset %}
{% do run_query(query) %}
{% endif %}

{% endfor %}

{% endif %}
Expand All @@ -115,4 +115,4 @@

{% endif %}

{% endmacro %}
{% endmacro %}