Skip to content

fix: make PushDownLeafProjections work with unnest#22620

Open
pabadrubio wants to merge 1 commit into
apache:mainfrom
pabadrubio:pabadrubio/fix-unnest-bug
Open

fix: make PushDownLeafProjections work with unnest#22620
pabadrubio wants to merge 1 commit into
apache:mainfrom
pabadrubio:pabadrubio/fix-unnest-bug

Conversation

@pabadrubio
Copy link
Copy Markdown

@pabadrubio pabadrubio commented May 29, 2026

Which issue does this PR close?

Closes #22615.

Rationale for this change

PushDownLeafProjections throws an error when it tries to push down an expression through an Unnest node. It also tries to push leaf projections incorrectly for Unnest nodes.

What changes are included in this PR?

This PR makes PushDownLeafProjections never push down leaf expressions through Unnest nodes. This avoids the code in try_push_into_inputs from calling:

let new_node = node.with_new_exprs(node.expressions(), new_inputs)?;

on an Unnest node, which doesn't work.

Changing that line is not enough, as even in that case the code in try_push_into_inputs to decide when to push down a projection is not valid for Unnest nodes, as explained in #22615

In this PR, I only want to make sure that the optimizer works for Unnest cases, but we could probably do better and allow leaf expressions push downs when the expression refer to a column that is not being unnested.

Are these changes tested?

Added unit tests and .slt tests for these cases.

Are there any user-facing changes?

No

@github-actions github-actions Bot added optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PushDownLeafProjections error with Unnest nodes

1 participant