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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: EnforceSorting should not remove a needed coalesces #14637
base: main
Are you sure you want to change the base?
fix: EnforceSorting should not remove a needed coalesces #14637
Changes from all commits
670eff3
0661ed7
89556c2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a refactor. See this commit.
parallelize_sorts
and its helperremove_bottleneck_in_subplan
removed more nodes than it should, including needed nodes. Those nodes were then added back in a few conditionals.PlanWithCorrespondingCoalescePartitions
and how it was built inupdate_coalesce_ctx_children
-- then (a) it avoids excess node removal, and also (b) we no longer need to add back nodes later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This single line is the fix for our found issue.
It's also isolated in it's own commit, with the fixed test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alamb -- lmk if you want the refactor to go in first, in a separate PR, before the the reproducer + fix PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
propagate
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think I need better words. 😆
The context is made to find linked Sort->Coalesce cascades.
This linkage is then used to say "if we find a sort, remove the linked coalesces from the subplan". Specifically, this code. If the link is broken, a.k.a. if
ctx.data=false
, then stop going down the subplan looking for coalesce to remove.So the link only exists as long as "no nodes" break the link.
Example of an unlinked Coalesce->Sort, since the aggregate requires the coalesce for single partitioned input:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be a better way to say/explain this? 🙏🏼
Maybe I should add docs to the
update_coalesce_ctx_children
which constructs this context? Or the wording on the current docs forPlanWithCorrespondingCoalescePartitions
? 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I got it.
Now I think current doc is very good. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the context refactor, the
remove_bottleneck_in_subplan
is no longer removing too many nodes.As a result, here we no longer have to add back the coalesce again (old line 310).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is about identifying (and removing) Repartition->Coalesce->Repartition, to make it only a singular repartition.
Since the removal decisions were already being made when the context is built, I consolidated this removal decision to the same place (
update_coalesce_ctx_children
).