Repository navigation
[branch-56] fix: preserve constant equivalence properties through projection (backport #27123) - #27179
Open
alamb wants to merge 1 commit into
Open
[branch-56] fix: preserve constant equivalence properties through projection (backport #27123)#27179alamb wants to merge 1 commit into
alamb wants to merge 1 commit into
Conversation
…che#27123) ## Which issue does this PR close? Closes apache#26624. ## Rationale for this change With `prefer_hash_join = false`, a query can fail physical plan validation when a filter makes a computed sort or join key constant. Embedding a projection into the sort-merge join loses the constant property after sorting has already relied on it. ## What changes are included in this PR? Preserve each projected equivalence class's constant metadata. A projected member has the same value as its source member on every row, and projection keeps rows in the same partitions. Its known value and uniform or partition-local status therefore still hold. Outer joins clear constants on the NULL-padded side before projecting their output. Partition merges clear `Heterogeneous` constants. Also preserve scalar-subquery leaves during indirect projection. They read a shared subquery result without depending on the input schema. The arithmetic `ORDER BY` reproduction needs the metadata copy; the scalar-subquery join reproduction needs both changes. ## What is the testing strategy for this PR? SQL cases in `joins.slt` cover arithmetic, `upper()`, left joins, and the scalar-subquery join. A NULL-padded left join checks that matched values sort before the NULL rows. The metadata unit test covers known, unknown, and partition-local constants, dropped arguments, and partition merging. The original SQL cases and metadata test fail before the fix and pass afterward. Validation includes the extended workspace tests, full lint suite, and strict all-features Clippy. ## Are there any user-facing changes? Affected queries plan and execute successfully. No public API changes. Needs a backport to `branch-56` for the 56.0.0 regression tracker (apache#24461). --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit ad8578a)
28 of 54 tasks
mbutrovich
approved these changes
Nov 6, 2026
mbutrovich
left a comment
Contributor
There was a problem hiding this comment.
Looks like a clean cherry-pick, approved pending CI. Thanks @alamb!
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## branch-56 #27179 +/- ##
=============================================
- Coverage 83.26% 83.26% -0.01%
=============================================
Files 1169 1169
Lines 474269 474302 +33
Branches 474269 474302 +33
=============================================
+ Hits 394908 394928 +20
- Misses 55455 55463 +8
- Partials 23906 23911 +5
... and 7 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
Which issue does this PR close?
branch-5656.0.0(Oct/Nov 2026) #24461EquivalenceGroupprojection) #26624