Skip to content

Support FilterExec with embedded projections in WindowTopN optimization #21596

@SubhamSinghal

Description

@SubhamSinghal

Is your feature request related to a problem or challenge?

Discussion thread

The WindowTopN physical optimizer rule currently skips FilterExec nodes that have an embedded projection (filter.projection().is_some()). This happens when ProjectionPushdown runs before WindowTopN and embeds a projection into the FilterExec.

// Don't handle filters with projections
if filter.projection().is_some() {
    return None;
} 

Describe the solution you'd like

Extend WindowTopN to handle FilterExec with embedded projections. This would require:

  1. Extracting the projection mapping from FilterExec
  2. Resolving the window column index through the projection (mapping projected column indices back to the original schema)
  3. Carrying the projection forward into the replacement plan (either re-wrapping PartitionedTopKExec with a ProjectionExec, or embedding the projection)

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions