Repository navigation
fix: skip volatile expressions when projecting equivalence classes - #27646
Draft
galaxytemple wants to merge 1 commit into
Draft
galaxytemple wants to merge 1 commit into
galaxytemple wants to merge 1 commit into
Conversation
# Conflicts: # datafusion/physical-expr/src/equivalence/class.rs
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?
Rationale for this change
When a projection outputs the same volatile expression more than once (e.g.
SELECT floor(random() * 3) AS x, floor(random() * 3) AS y),EquivalenceGroup::projectgroups both targets under the same source expression key and placesxandyin the same equivalence class (x = y).And this false
x = yequivalence causes downstreamORDER BY x, y(including acrossUNION ALLafter #27347) to dropyfromSortExecand return rows unsorted ony.What changes are included in this PR?
is_volatile(source)) at the start of themapping.iter()loop inEquivalenceGroup::projectso they do not form equivalence classes across projected targets.class.rsand a sqllogictest inunion.slt.What is the testing strategy for this PR?
Unit test (
class.rs):Volatility::VolatileUDF expressionf(a)to two target columns (xandy) viaProjectionMappingand asserts thatEquivalenceGroup::projectreturns an empty group (projected.is_empty()) instead ofx=y.Sqllogictest (
union.slt):ORDER BY x, yon aUNION ALLquery projectingfloor(random() * 3) AS x, floor(random() * 3) AS yand checks the physical plan to verify thatxandyare not treated as equivalent (both remain inSortExec).Are there any user-facing changes?
No API changes. Bug fix only.