Skip to content

Propagate orderings through struct-producing projections #21217

Description

@rkrishn7

Is your feature request related to a problem or challenge?

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 because ProjectionMapping maps the entire named_struct(...) expression to col("details").

Notably, there is no field-level decomposition, so it can't prove that get_field(details, "ticker") actually preserves the ordering of the input ticker column. This means ORDER BY details['ticker'] will require a SortExec, even when the input is already sorted by ticker.

Describe the solution you'd like

Add ScalarUDFImpl::struct_field_mapping that struct-producing UDFs can implement to declare their field-to-input-arg relationships, which ProjectionMapping then uses to add field-level entries so EquivalenceProperties can propagate orderings through the struct boundary.

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. added theissue type on Mar 28, 2026
  2. rkrishn7 commented on Mar 28, 2026

    @rkrishn7
    ContributorAuthor

    take

  3. added a commit that references this issue on Apr 8, 2026
    944bac2
  4. added a commit that references this issue on Apr 8, 2026
    fdf8466
  5. added a commit that references this issue on Apr 21, 2026
    b4b7be6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions