Skip to content

Commit

Permalink
Add SavedQuery nodes to grouping process
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
QMalcolm committed Oct 10, 2023
1 parent d64ab57 commit 396ea4f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ====================================
Expand Down
6 changes: 5 additions & 1 deletion core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
Macro,
Exposure,
Metric,
SavedQuery,
SeedNode,
SemanticModel,
ManifestNode,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions core/dbt/parser/schema_yaml_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 396ea4f

Please sign in to comment.