-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add tests for Demonstrate EnforceSorting can remove a needed coalesce #14919
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
Merged
alamb
merged 1 commit into
apache:main
from
influxdata:14691/add-test-to-demonstrate-bug
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
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.
Did you intentionally put
SinglePartitionedaggregate mode? The input is only 1 partition, so why don't you use AggregateMode::Single? I'm unsure if this is a valid case @wiedld @alambThere 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.
When I update the mode as
Single, there seems no problem to meUh oh!
There was an error while loading. Please reload this page.
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.
Thank you for taking the time @berkaysynnada .
The test case merged here is a minimal reproducer. The
mode=SinglePartitionedis coming from the actual plans we have running and failing in prod: influxdata#58 (comment)A simplified view of it is:
The coalesce gets removed for the
mode=SinglePartitioned. Do you think that the bug is elsewhere?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.
It means that when an
AggregateExecisSinglePartitioned, then its input should be multi-partitioned (I should say the wording is a bit confusing -- SinglePartitioned means Single layer of aggregation, but its input is Partitioned). However, in your example plan,AggregateExechas a single partition (as it is above CoalescePartitions). So, what I was trying to say that your initial plan should cannot ever exists in general conditions. I'd also like to remind that; EnforceSorting can handle invalid plans and make them valid in terms of ordering conditions (and expects valid distribution conditions), and EnforceDistribution does the same for distribution conditions (and again expects valid ordering conditions). However, in this reproducer, you are giving an invalid plan to the EnforceSorting in terms of distribution.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 see -- so you are saying that if the input to the AggregateExec has only a single partitition, then it should never be
SinglePartitioned.So you are saying that the input plan is not valid and thus the error is elsewhere (whatever generated this plan).
I will make a PR to clarify the documentation as I agree it is quite confusing
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.
Proposed documentation PR:
AggregateMode#14946Uh oh!
There was an error while loading. Please reload this page.
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 think this means that the insertion of the coalesce in the first place (during the enforce distribution) is the bug. Since the input into the enforce distribution optimizer is:
Our Union outputs multiple partitions, and the AggregateExec;mode=Partial can take multiple partitions. Therefore the enforce distribution should not have inserted the coalesce?
I'll start by updating the reproducer test cases. Thank you.
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.
In a previous reproducer, I showed how the enforce distribution was inserting the coalesce.
See here: influxdata#58 (comment)
On the latest main, we no longer have the coalesce being inserted.
See here: #14949 (comment)
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'm going to revert this PR, with this 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.
It might insert a coalesce, but then it has to update
AggregateExec: mode=FinalPartitionedtoAggregateExec: mode=Final