From 396ea4f92b4c743a5c80382b3d1d87baf19b5f9b Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Tue, 10 Oct 2023 03:10:13 -0700 Subject: [PATCH] Add SavedQuery nodes to grouping process Our grouping logic seems to be in a weird spot. It seems liek we're moving to setting the `group` for a node in the node's `config` however, all of the logic around grouping is still focused on the top level `group` property on a nodes. To get group stuff plumbed I've thus added `group` as a top level property of the `SavedQuery` node, and populated it from the config group value. --- core/dbt/contracts/graph/nodes.py | 1 + core/dbt/parser/manifest.py | 6 +++++- core/dbt/parser/schema_yaml_readers.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 2306d92b708..5c4928dc893 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -1743,6 +1743,7 @@ class SavedQuery(GraphNode): metadata: Optional[SourceFileMetadata] = None config: SavedQueryConfig = field(default_factory=SavedQueryConfig) unrendered_config: Dict[str, Any] = field(default_factory=dict) + group: Optional[str] = None # ==================================== diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py index 7a1c4db1d29..5c2d11dda8a 100644 --- a/core/dbt/parser/manifest.py +++ b/core/dbt/parser/manifest.py @@ -94,6 +94,7 @@ Macro, Exposure, Metric, + SavedQuery, SeedNode, SemanticModel, ManifestNode, @@ -1236,12 +1237,15 @@ def check_valid_group_config(self): for semantic_model in manifest.semantic_models.values(): self.check_valid_group_config_node(semantic_model, group_names) + for saved_query in manifest.saved_queries.values(): + self.check_valid_group_config_node(saved_query, group_names) + for node in manifest.nodes.values(): self.check_valid_group_config_node(node, group_names) def check_valid_group_config_node( self, - groupable_node: Union[Metric, SemanticModel, ManifestNode], + groupable_node: Union[Metric, SavedQuery, SemanticModel, ManifestNode], valid_group_names: Set[str], ): groupable_node_group = groupable_node.group diff --git a/core/dbt/parser/schema_yaml_readers.py b/core/dbt/parser/schema_yaml_readers.py index 77632c4b5ef..0c538a602f9 100644 --- a/core/dbt/parser/schema_yaml_readers.py +++ b/core/dbt/parser/schema_yaml_readers.py @@ -705,6 +705,7 @@ def parse_saved_query(self, unparsed: UnparsedSavedQuery) -> None: where=[WhereFilter(where_sql_template=where_str) for where_str in unparsed.where], config=config, unrendered_config=unrendered_config, + group=config.group, ) # Only add thes saved query if it's enabled, otherwise we track it with other diabled nodes