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

Attempt to skip saved query processing when no semantic manifest changes #10784

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Sep 26, 2024

Resolves #10563

Problem

We run "process_saved_queries" even when nothing has changed in the semantic manifest.

Solution

Check for changes to saved queries, semantic models, and metrics before executing process saved queries. This will have false positives because of cascading re-parsing, but will enable us to skip at least some unnecessary saved query processing.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@gshank gshank requested a review from a team as a code owner September 26, 2024 14:15
@cla-bot cla-bot bot added the cla:yes label Sep 26, 2024
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.31%. Comparing base (ac66f91) to head (cebb1ce).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10784      +/-   ##
==========================================
- Coverage   89.00%   86.31%   -2.69%     
==========================================
  Files         181      182       +1     
  Lines       23126    23297     +171     
==========================================
- Hits        20583    20109     -474     
- Misses       2543     3188     +645     
Flag Coverage Δ
integration 86.31% <100.00%> (+0.11%) ⬆️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 86.31% <100.00%> (-2.69%) ⬇️
Integration Tests 86.31% <100.00%> (+0.11%) ⬆️

Copy link
Member

@aranke aranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

# because they refer to some other changed node, so there will be
# false positives. Ideally we would compare actual changes.
semantic_manifest_changed = False
SemanticManifestNode = Union[SavedQuery, SemanticModel, Metric]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we put this definition in a constants file somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it to core/dbt/contracts/graph/nodes.py

self.manifest.semantic_models.values(),
self.manifest.metrics.values(),
)
for node in semantic_manifest_nodes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This can be simplified to

if any(node.created_at > self.started_at for node in semantic_manifest_nodes):
    return

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic of "any" is backward, we want to execute the process metrics for node code instead of returning, but doing it that way would make merging into dbt-mantle more muddy because it executes a different function, so I'm going to leave this as it is.

@gshank gshank merged commit 1fe9c1b into main Sep 26, 2024
65 of 66 checks passed
@gshank gshank deleted the check_for_unchanged_semantic_manifest branch September 26, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not execute process_saved_queries if nothing in semantic manifest has changed
3 participants