-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ADAP-835: Optimize manual refresh on auto-refreshed materialized views #8847
base: main
Are you sure you want to change the base?
Conversation
…bt with no changes
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #8847 +/- ##
==========================================
- Coverage 86.35% 86.30% -0.06%
==========================================
Files 177 179 +2
Lines 26383 26453 +70
==========================================
+ Hits 22784 22829 +45
- Misses 3599 3624 +25
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
…esh before manually refreshing in the materialization
… into the base relation config
@@ -66,31 +65,16 @@ def from_dict(cls, config_dict: dict) -> "PostgresMaterializedViewConfig": | |||
return materialized_view | |||
|
|||
@classmethod | |||
def from_model_node(cls, model_node: ModelNode) -> "PostgresMaterializedViewConfig": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to RelationConfigBase
} | ||
return config_dict | ||
|
||
@classmethod | ||
def from_relation_results( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to RelationConfigBase
@@ -36,7 +37,6 @@ class PostgresMaterializedViewConfig(RelationConfigBase, RelationConfigValidatio | |||
""" | |||
|
|||
table_name: str = "" | |||
query: str = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not used, and is the only difference in this context between a ModelNode and a ParsedNode
resolves #6911
Problem
dbt run
will issue a manual refresh of a materialized view if there are no changes detected during a run. This happens regardless of whether the materialized view is setup to be automatically refreshed. If the materialized view is already scheduled to be refreshed, there is no need to insert an additional refresh. This will add cost and potentially introduce unexpected data as the refresh schedule will not match what's set with the extra refresh.Solution
dbt will inspect the materialized view to determine if it is set to automatically refresh. If it is, and there are no changes, then
dbt run
will do nothing. If it is not set to automatically refresh, thendbt run
will issue a refresh command.Checklist