-
Notifications
You must be signed in to change notification settings - Fork 0
18674: chore: Refactor with assert_or_internal_err!() in datafusion/spark. #25
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,7 +238,10 @@ mod tests { | |
| use arrow::array::{Float64Array, Int32Array, IntervalMonthDayNanoArray}; | ||
| use arrow::datatypes::Field; | ||
| use datafusion_common::config::ConfigOptions; | ||
| use datafusion_common::{internal_datafusion_err, internal_err, Result}; | ||
| use datafusion_common::{ | ||
| assert_eq_or_internal_err, assert_or_internal_err, internal_datafusion_err, | ||
| Result, | ||
| }; | ||
|
|
||
| use super::*; | ||
| fn run_make_interval_month_day_nano(arrs: Vec<ArrayRef>) -> Result<ArrayRef> { | ||
|
|
@@ -533,36 +536,41 @@ mod tests { | |
| .ok_or_else(|| { | ||
| internal_datafusion_err!("expected IntervalMonthDayNanoArray") | ||
| })?; | ||
| if arr.len() != number_rows { | ||
| return internal_err!( | ||
| "expected array length {number_rows}, got {}", | ||
| arr.len() | ||
| ); | ||
| } | ||
| assert_eq_or_internal_err!( | ||
| arr.len(), | ||
| number_rows, | ||
| "expected array length {number_rows}, got {}", | ||
| arr.len() | ||
| ); | ||
| for i in 0..number_rows { | ||
| let iv = arr.value(i); | ||
| if (iv.months, iv.days, iv.nanoseconds) != (0, 0, 0) { | ||
| return internal_err!( | ||
| "row {i}: expected (0,0,0), got ({},{},{})", | ||
| iv.months, | ||
| iv.days, | ||
| iv.nanoseconds | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| ColumnarValue::Scalar(ScalarValue::IntervalMonthDayNano(Some(iv))) => { | ||
| if (iv.months, iv.days, iv.nanoseconds) != (0, 0, 0) { | ||
| return internal_err!( | ||
| "expected scalar 0s, got ({},{},{})", | ||
| assert_eq_or_internal_err!( | ||
| (iv.months, iv.days, iv.nanoseconds), | ||
| (0, 0, 0), | ||
| "row {i}: expected (0,0,0), got ({},{},{})", | ||
| iv.months, | ||
| iv.days, | ||
| iv.nanoseconds | ||
| ); | ||
| } | ||
| } | ||
| ColumnarValue::Scalar(ScalarValue::IntervalMonthDayNano(Some(iv))) => { | ||
| assert_eq_or_internal_err!( | ||
| (iv.months, iv.days, iv.nanoseconds), | ||
| (0, 0, 0), | ||
| "expected scalar 0s, got ({},{},{})", | ||
| iv.months, | ||
| iv.days, | ||
| iv.nanoseconds | ||
| ); | ||
| } | ||
| other => { | ||
| return internal_err!( | ||
| assert_or_internal_err!( | ||
| matches!( | ||
| other, | ||
| ColumnarValue::Array(_) | ||
| | ColumnarValue::Scalar(ScalarValue::IntervalMonthDayNano(_)) | ||
| ), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Match Arm Logic Inversion: Incorrect Control FlowThe assertion logic is inverted in the match arm. The old code unconditionally returned an error for any value in the
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:useful; category:bug; feedback:The Bugbot AI reviewer is correct! The check seems wrong for two reasons: 1) ColumnarValue::Array(arr) is already covered earlier in the first arm of the match; 2) ColumnarValue::Scalar(ScalarValue::IntervalMonthDayNano(_)) could match only for |
||
| "expected Array or Scalar IntervalMonthDayNano, got {other:?}" | ||
| ); | ||
| } | ||
|
|
||
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.
Consider preserving the actual argument count in the error message (e.g., include
got {}withargs.len()), as the previous version provided this detail; this regression also appears in similar checks (crc32, sha1, last_day).🤖 Was this useful? React with 👍 or 👎
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.
value:useful; category:bug; feedback:The Augment AI reviewer is correct that useful debug information is lost in this change and it should be reverted. Prevents harder debugging when the error occurs.