-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 panic in array_agg(distinct) query #10526
Conversation
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
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 the quick work @jayzhan211 -- very nice
states[0] | ||
.as_list::<i32>() | ||
.iter() | ||
.flatten() |
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 does the flatten do? Discard Option
?
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.
yes
3 1 | ||
|
||
# It has only AggregateExec with FinalPartitioned mode, so `merge_batch` is used | ||
# If the plan is changed, whether the `merge_batch` is used should be verified to ensure the test coverage |
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.
💯 for the explanatory comments about why this explain is here
@@ -198,6 +198,73 @@ statement error This feature is not implemented: LIMIT not supported in ARRAY_AG | |||
SELECT array_agg(c13 LIMIT 1) FROM aggregate_test_100 | |||
|
|||
|
|||
# Test distinct aggregate function with merge batch |
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 ran the test without the changes in this PR and it panic'd as expected:
cargo test --test sqllogictests
...
thread 'tokio-runtime-worker' panicked at datafusion/physical-expr/src/aggregate/array_agg_distinct.rs:158:9:
assertion `left == right` failed: state array should only include 1 row!
left: 5
right: 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@@ -153,12 +153,11 @@ impl Accumulator for DistinctArrayAggAccumulator { | |||
return Ok(()); | |||
} | |||
|
|||
let array = &states[0]; | |||
|
|||
assert_eq!(array.len(), 1, "state array should only include 1 row!"); |
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.
Is it okay that we just delete the assertion?
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.
yes, because it is no longer true, this PR is dealing with the array that has len more than one
Thanks @alamb ! |
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com> (cherry picked from commit 626c6bc)
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com> (cherry picked from commit 626c6bc)
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Which issue does this PR close?
Closes #10486 .
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?