Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Mar 20, 2024

Which issue does this PR close?

Follow on to #9679

Rationale for this change

@Omega359 pointed out that the use of expect would panic on unexpected results: #9679 (comment)

What changes are included in this PR?

Change a panic into an internal error

Are these changes tested?

No (it is "impossible" to hit this code)

Are there any user-facing changes?

Better UX on unexpected error

@alamb alamb marked this pull request as ready for review March 20, 2024 17:30
@github-actions github-actions bot added the physical-expr Changes to the physical-expr crates label Mar 20, 2024
@Dandandan Dandandan changed the title Minor: return internal error rather than panic on unexpected error in COUNT DISTICT Minor: return internal error rather than panic on unexpected error in COUNT DISTINCT Mar 20, 2024
assert_eq!(states.len(), 1, "array_agg states must be singleton!");
let array = &states[0];
let list_array = array.as_list::<i32>();
for inner_array in list_array.iter() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just filter out Nones? just thinking

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think filtering out nulls would potentially silently ignore errors

I think the rationale goes like

  1. This code is used to combine multiple partial results (the results of calling Self::state())
  2. Since Self::state never returns None -- it always returns Ok(vec![ScalarValue::List(arr)]) then this merge code should never receive a None

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thanks @alamb for explanation

@alamb alamb merged commit 6d74025 into apache:main Mar 21, 2024
@alamb
Copy link
Contributor Author

alamb commented Mar 21, 2024

Thanks for the review @comphead

@alamb alamb deleted the alamb/do_not_panic branch March 21, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants