v3 SQL: dim-link-aware filter pushdown into inner subquery scopes#2170
Merged
Conversation
✅ Deploy Preview for thriving-cassata-78ae72 canceled.
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR overhauls how
_resolve_pushdown_filters_for_ctedecides where to inject user-supplied dimension filters within a CTE body, closing several regressions in the original "walk every source-table reference" pass (#2166) and bringing v3's pushdown placement closer to v2's behavior.For context, the filter pushdown in v3 had two known regressions as compared to v2:
Earlier attempts to fix these (the "walk every source-table reference" change) also went too far: they pushed filters into tables that incidentally shared a column name with the filter's dim but weren't actually linked to it, diverging from v2.
_resolve_pushdown_filters_for_ctenow does two complementary passes:target_select, find every siblingast.Tableref to the same physical source elsewhere in the CTE body and inject a retargeted copy. Restores the v2 partition-prune-everywhere behavior for self-references.ast.Selectscope inside the CTE body (including secondary set-op arms), builds a resolver map from:FROM, register one entry perforeign_keys_reversedrow from its dimension links. This is the only route by which filters get pushed at inner scopes.Test Plan
make checkpassesmake testshows 100% unit test coverageDeployment Plan