-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ParallelizeSorts, a subrule of EnforceSorting optimizer, should not remove necessary coalesce. #14691
Labels
bug
Something isn't working
Comments
take |
I believe in https://github.com/apache/datafusion/pull/14919/files#r1975931108 @berkaysynnada is saying that the input plan is not valid:
|
Update:
|
So does this mean that whatever issue we were hitting has been fixed on main (in Datafusion 46?)
|
yes, it should be. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
During the EnforceSorting optimizer run, a valid plan may be turned invalid due to the removal of a necessary coalesce. The result is a planning time failure in the SanityChecker due to
does not satisfy distribution requirements: HashPartitioned[[a@0]]). Child-0 output partitioning: UnknownPartitioning(2)
.We start with a valid input plan:
And a coalesce is removed to make it invalid:
To Reproduce
A test case demonstrates this: 670eff3
We discovered this bug using our own constructed (and valid) LogicalPlans, which were converted to a physical plan using the default planner, and then had a coalesce inserted during the EnforceDistribution optimizer pass (to handle the
UnionExec -> AggregateExec
distribution requirements). The EnforceSorting would then remove the coalesce, thereby rendering the plan invalid once again. We do not feel this is unique to our plans, rather, that this behavior in the EnforceSorting is a bug which could impact others too.Expected behavior
EnforceSorting should not take a valid plan, and make it invalid -- thereby causing failure in the planning sanity check.
Additional context
We already have a proposed solution: #14637While debugging, I did a minor refactor toparalelize_sorts
and its helperremove_bottleneck_in_subplan
. The reason for the refactor (also summarized here), was that I noticed a pattern of several necessary nodes being removed -- and then added back later. I elected to simplify the code by tightening up how we build thePlanWithCorrespondingCoalescePartitions
, in order to correctly identify what nodes should be removed in the first place -- and then only removing those nodes. The refactor is isolated in this commit: 0661ed7Update:
pushdown_sorts
subrule.The text was updated successfully, but these errors were encountered: