-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix Partial AggregateExec correctness issue dropping rows #18712
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
base: main
Are you sure you want to change the base?
Conversation
| // Check if we should switch to skip aggregation mode | ||
| // It's important that we do this before we early emit since we've | ||
| // already updated the probe. | ||
| if let Some(new_state) = self.switch_to_skip_aggregation()? { |
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's unclear to me why we set update_skip_aggregation_probe here https://github.com/apache/datafusion/pull/18712/files#diff-69c8ecaca5e2c7005f2ed1facaa41f80b45bfd006f2357e53ff3072f535c287dL687 and not next to switch_to_skip_aggregation. I can't fully give an explanation yet but allowing the probe to be updated and then allowing the look to break before we get here seems dangerous? It's important that we emit everything before we move to the SkipAggregation state?
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.
@korowa does that make sense to you?
b28fce0 to
353b11b
Compare
90d5a48 to
febdd78
Compare
|
|
||
| ExecutionState::Done => { | ||
| // Sanity check: all groups should have been emitted by now | ||
| if !self.group_values.is_empty() { |
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.
Adding some protection here to try and avoid bugs like this happening in the future.
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'd rather fail the query than return the wrong / incomplete results.
Which issue does this PR close?
More detail is in the issue.
Rationale for this change
This is a pretty major correctness issue.
What changes are included in this PR?
Fixes issue and reorders skip aggregate and emit early within partial aggregate execution
Are these changes tested?
Yes, the unit test that's added here previously failed before this change.
Are there any user-facing changes?