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

feature: Update Dynamic table parameters on materialization #893

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions dbt/adapters/snowflake/relation_configs/dynamic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class SnowflakeDynamicTableConfig(SnowflakeRelationConfigBase):
query: str
target_lag: str
snowflake_warehouse: str
refresh_mode: str
initialize: str
comment: Optional[str] = None

@classmethod
def from_dict(cls, config_dict) -> "SnowflakeDynamicTableConfig":
Expand All @@ -42,6 +45,9 @@ def from_dict(cls, config_dict) -> "SnowflakeDynamicTableConfig":
"query": config_dict.get("query"),
"target_lag": config_dict.get("target_lag"),
"snowflake_warehouse": config_dict.get("snowflake_warehouse"),
"refresh_mode": config_dict.get("refresh_mode"),
"initialize": config_dict.get("initialize"),
"comment": config_dict.get("comment"),
}

dynamic_table: "SnowflakeDynamicTableConfig" = super().from_dict(kwargs_dict) # type: ignore
Expand All @@ -56,6 +62,9 @@ def parse_relation_config(cls, relation_config: RelationConfig) -> Dict[str, Any
"query": relation_config.compiled_code, # type: ignore
"target_lag": relation_config.config.extra.get("target_lag"), # type: ignore
"snowflake_warehouse": relation_config.config.extra.get("snowflake_warehouse"), # type: ignore
"refresh_mode": relation_config.config.extra.get("refresh_mode"), # type: ignore
"initialize": relation_config.config.extra.get("initialize"), # type: ignore
"comment": relation_config.config.extra.get("comment"), # type: ignore
}

return config_dict
Expand All @@ -71,6 +80,9 @@ def parse_relation_results(cls, relation_results: RelationResults) -> Dict:
"query": dynamic_table.get("text"),
"target_lag": dynamic_table.get("target_lag"),
"snowflake_warehouse": dynamic_table.get("warehouse"),
"refresh_mode": dynamic_table.get("refresh_mode"), # Should I set defaults here or do they get passed as null
"initialize": dynamic_table.get("initialize"), # Should I set defaults here or do they get passed as null
HenkvanDyk marked this conversation as resolved.
Show resolved Hide resolved
"comment": dynamic_table.get("comment"),
}

return config_dict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

create dynamic table {{ relation }}
target_lag = '{{ config.get("target_lag") }}'
refresh_mode = '{{ config.get("refresh_mode") }}'
initialize = '{{ config.get("initialize") }}'
warehouse = {{ config.get("snowflake_warehouse") }}
{% if config.get("comment") %}
comment = '{{ config.get("comment") }}'
{% endif %}
as (
{{ sql }}
)
Expand Down