-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Issue 19781 : Internal error: Assertion failed: !self.finished: LimitedBatchCoalescer #19785
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
+55
−46
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
30a693c
Fix: filter with limit support raises internal error (slt test)
95b675e
fix: filter with limit support raises internal error
b2b8a23
Fix: filter with limit support raises internal error (tackled review …
fc37c87
Fix: filter with limit support raises internal error (tackled review …
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
22 changes: 22 additions & 0 deletions
22
datafusion/sqllogictest/test_files/limit_single_row_batches.slt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
|
|
||
| # minimize batch size to 1 in order to trigger different code paths | ||
| statement ok | ||
| set datafusion.execution.batch_size = '1'; | ||
|
|
||
| # ---- | ||
| # tests with target partition set to 1 | ||
| # ---- | ||
| statement ok | ||
| set datafusion.execution.target_partitions = '1'; | ||
|
|
||
|
|
||
| statement ok | ||
| CREATE TABLE filter_limit (i INT) as values (1), (2); | ||
|
|
||
| query I | ||
| SELECT COUNT(*) FROM (SELECT i FROM filter_limit WHERE i <> 0 LIMIT 1); | ||
| ---- | ||
| 1 | ||
|
|
||
| statement ok | ||
| DROP TABLE filter_limit; |
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.
I think this is the key change -- specifically that on subsequent calls to
poll_next()we just drain the coalescer and don't get the next input / try and put it in.Previously, if the input returns another batch, the FilterExec will try and add it to the BatchCoalescer (which is what triggers the assert)
This new code correctly drains the coalescer state 👍 .
I suspect that we haven't seen this on other queries because most/all the ExecutionPlans that can feed a FilterExec also implement Limit. Thus when the FilterExec calls
poll_nexton the input, the input returns None and no additional batch is pushed to the BatchCoalescer.The default batch size for the memory exec means that it will most often only return a single batch.
I can't really figure out why setting the number of target partitions to 1 makes any difference (though I verified it is required to trigger the reproducer)
Perhaps the reason @bert-beyondloops saw this in his system is that you have some custom execution plan (that doesn't implement limit pushdown 🤔 ). This is fine I am just trying to explain why we haven't hit this issue before / in our other tests
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.
We indeed specify target partition 1 for some specific case since we know upfront our input is sorted and we do not want overhead of a SortMergeExec.
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.
Without the target partition set to 1, you get another physical plan (with multiple partitions) and where the limit is foreseen on another type of Exec.