Skip to content

Commit

Permalink
Attempt to skip saved query processing when no semantic manifest chan…
Browse files Browse the repository at this point in the history
…ges (#10784)
  • Loading branch information
gshank authored Sep 26, 2024
1 parent 41e4836 commit 1fe9c1b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240926-101220.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Attempt to skip saved query processing when no semantic manifest changes
time: 2024-09-26T10:12:20.193453-04:00
custom:
Author: gshank
Issue: "10563"
1 change: 1 addition & 0 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,7 @@ class ParsedSingularTestPatch(ParsedPatch):

TestNode = Union[SingularTestNode, GenericTestNode]

SemanticManifestNode = Union[SavedQuery, SemanticModel, Metric]

RESOURCE_CLASS_TO_NODE_CLASS: Dict[Type[BaseResource], Type[BaseNode]] = {
node_class.resource_class(): node_class
Expand Down
18 changes: 18 additions & 0 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
ResultNode,
SavedQuery,
SeedNode,
SemanticManifestNode,
SemanticModel,
SourceDefinition,
)
Expand Down Expand Up @@ -1141,6 +1142,23 @@ def process_metrics(self, config: RuntimeConfig):

def process_saved_queries(self, config: RuntimeConfig):
"""Processes SavedQuery nodes to populate their `depends_on`."""
# Note: This will also capture various nodes which have been re-parsed
# because they refer to some other changed node, so there will be
# false positives. Ideally we would compare actual changes.
semantic_manifest_changed = False
semantic_manifest_nodes: chain[SemanticManifestNode] = chain(
self.manifest.saved_queries.values(),
self.manifest.semantic_models.values(),
self.manifest.metrics.values(),
)
for node in semantic_manifest_nodes:
# Check if this node has been modified in this parsing run
if node.created_at > self.started_at:
semantic_manifest_changed = True
break # as soon as we run into one changed node we can stop
if semantic_manifest_changed is False:
return

current_project = config.project_name
for saved_query in self.manifest.saved_queries.values():
# TODO:
Expand Down

0 comments on commit 1fe9c1b

Please sign in to comment.