Skip to content
Prev Previous commit
Next Next commit
add test
  • Loading branch information
EmilyMatt committed Nov 9, 2025
commit 0791062c3e752668c78be194db50d95025082d82
22 changes: 22 additions & 0 deletions datafusion/expr-common/src/columnar_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,28 @@ mod tests {
use super::*;
use arrow::array::Int32Array;

#[test]
fn into_array_of_size() {
// Array case
let arr = make_array(1, 3);
let arr_columnar_value = ColumnarValue::Array(Arc::clone(&arr));
assert_eq!(&arr_columnar_value.into_array_of_size(3).unwrap(), &arr);

// Scalar case
let scalar_columnar_value = ColumnarValue::Scalar(ScalarValue::Int32(Some(42)));
let expected_array = make_array(42, 100);
assert_eq!(
&scalar_columnar_value.into_array_of_size(100).unwrap(),
&expected_array
);

// Array case with wrong size
let arr = make_array(1, 3);
let arr_columnar_value = ColumnarValue::Array(Arc::clone(&arr));
let result = arr_columnar_value.into_array_of_size(5);
assert!(result.is_err());
Copy link
Member

Choose a reason for hiding this comment

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

can you validate the exact error as it can return different error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

#[test]
fn values_to_arrays() {
// (input, expected)
Expand Down