Skip to content

[branch-54] Gate new ScalarSubqueryExec node behind session property (#22530)#22690

Merged
alamb merged 1 commit into
apache:branch-54from
LiaCastaneda:lia/backport-pr-22530
Jun 1, 2026
Merged

[branch-54] Gate new ScalarSubqueryExec node behind session property (#22530)#22690
alamb merged 1 commit into
apache:branch-54from
LiaCastaneda:lia/backport-pr-22530

Conversation

@LiaCastaneda
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • Closes #.

Rationale for this change

This PR backports #22530

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added documentation Improvements or additions to documentation optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) common Related to common crate labels Jun 1, 2026
@LiaCastaneda LiaCastaneda changed the title Gate new ScalarSubqueryExec node behind session property (#22530) [branch-54] Gate new ScalarSubqueryExec node behind session property (#22530) Jun 1, 2026
Comment thread datafusion/sqllogictest/test_files/subquery.slt Outdated
@LiaCastaneda
Copy link
Copy Markdown
Contributor Author

rebasing this since the other PR was merged

Related to discussion on apache#21240 and
apache#21080 (comment).

PR apache#21240 introduced `ScalarSubqueryExec` / `ScalarSubqueryExpr` to
execute uncorrelated scalar subqueries during physical execution. The
two communicate via shared in process state (a `slot` in
`ExecutionProps`), which breaks distributed execution that may split
execution across a network boundary between the producer
(`ScalarSubqueryExec`) and the consumer expression
(`ScalarSubqueryExpr`). See more details on this explanation in
[datafusion-contrib/datafusion-distributed#460](datafusion-contrib/datafusion-distributed#460)

Adds a new optimizer config option
`datafusion.optimizer.enable_physical_uncorrelated_scalar_subquery`
(default true, preserving the current behavior). When true (default),
behavior is unchanged from current main; when false, all scalar
subqueries are rewritten to left joins by `ScalarSubqueryToJoin` and
`ScalarSubqueryExec` is never constructed (which was the previous
behavior).

Yes all tests pass and added
`uncorrelated_scalar_subquery_rewritten_when_flag_off` to test the
negative case.

Yes, a new config option
`datafusion.optimizer.physical_uncorrelated_scalar_subquery` (this just
changes the way the query is executed but not the results)
@LiaCastaneda LiaCastaneda force-pushed the lia/backport-pr-22530 branch 2 times, most recently from 1636330 to 84415ce Compare June 1, 2026 14:44
@LiaCastaneda
Copy link
Copy Markdown
Contributor Author

LiaCastaneda commented Jun 1, 2026

rebased. I added back the failing test

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me -- thank you @LiaCastaneda

Copy link
Copy Markdown
Contributor

@gabotechs gabotechs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice

@alamb alamb merged commit dbd97e6 into apache:branch-54 Jun 1, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate core Core DataFusion crate documentation Improvements or additions to documentation optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants