Repository navigation
Conversation
…tatic planner The static planner left the coalesce over a null-aware join's probe side inside the join's stage. An aggregate above the join reran EnsureRequirements over that stage and removed the coalesce, so the join ran as several tasks and emitted unmatched build rows once per task. Close the stage at the join so no later pass sees the coalesce. Closes apache#2849.
milenkovicm
approved these changes
Nov 19, 2026
milenkovicm
left a comment
Contributor
There was a problem hiding this comment.
thanks @ewoodbury one nit to be considered
| // default adaptive planner; "rewrite_disabled_static" does the same | ||
| // under the static planner. Both run one partition per task, as on a | ||
| // cluster. | ||
| for variant in [ |
Contributor
There was a problem hiding this comment.
nit: The PR body says pipelined mode is affected too, because it always uses the static planner. Would it make sense to test it ?
Contributor
Author
There was a problem hiding this comment.
Yeah definitely - pushed up a quick test covering pipelined mode
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.
Which issue does this PR close?
Closes #2849.
Rationale for this change
A
NOT INsubquery that stays a null-aware anti join has to read the whole subquery result in one task to be correct. The static planner gets that by putting a coalesce in front of the join, but when there's an aggregate above the join, the planner later removes that coalesce. The join then runs as several tasks, and each one returns its own copy of the rows it didn't match.Example: with the static planner and the
NOT INrewrite turned off, this query over a 4-filet2returns 26/26/23 instead of 5/5/5:It only happens with the static planner (or pipelined mode, which always uses it). Default settings don't hit it.
What changes are included in this PR?
The static planner now ends the stage right after a null-aware join, so nothing planned above it can remove the coalesce. The subquery side is still read in parallel. The cost is one extra stage, carrying the join's output, which is never larger than the table the join already holds in memory.
A one-partition coalesced shuffle reader would avoid the extra stage, but the static planner doesn't support those yet, so that's left as a follow-up.
Tests: the
null_awareclient test gets a static-planner case and aGROUP BYquery (that combination fails on main), and a planner test checks the new stage.Are there any user-facing changes?
Correct results.
EXPLAINshows one more stage for null-aware anti joins under the static planner.