feat: Propagate orderings through struct-producing projections#39
Merged
feat: Propagate orderings through struct-producing projections#39
Conversation
zhuqi-lucas
approved these changes
Mar 27, 2026
Collaborator
zhuqi-lucas
left a comment
There was a problem hiding this comment.
LGTM! Clean design and good test coverage.
One issue: is_multiple_of in named_struct.rs:190 is nightly-only (feature(unsigned_is_multiple_of)). This will fail on stable Rust. Should use literal_args.len() % 2 != 0 instead.
xudong963
approved these changes
Mar 27, 2026
Collaborator
Author
Thanks @zhuqi-lucas
clippy actually instructed me to use |
rkrishn7
added a commit
that referenced
this pull request
Mar 27, 2026
rkrishn7
added a commit
that referenced
this pull request
Mar 27, 2026
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.
When a projection wraps columns into a struct via
named_struct(e.g.,named_struct('ticker', ticker, ...) AS details), the optimizer loses track of the input column's ordering becauseProjectionMappingmaps the entirenamed_struct(...)expression tocol("details"). Notably, it has no field-level decomposition, so it can't prove thatget_field(details, "ticker")actually preserves the ordering of the input ticker column. This meansORDER BY details['ticker']will require aSortExec, even when the input is already sorted byticker.This PR fixes this by adding
ScalarUDFImpl::struct_field_mappingthat struct-producing UDFs can implement to declare their field-to-input-arg relationships, whichProjectionMappingthen uses to add field-level entries soEquivalencePropertiescan propagate orderings through the struct boundary.