Skip to content

Commit 91612a4

Browse files
committed
chore: add tests
1 parent bdba08a commit 91612a4

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

datafusion/physical-expr/src/array_expressions.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,17 @@ mod tests {
21612161
#[test]
21622162
fn test_return_large_array() {
21632163
let list_array = return_large_array();
2164-
assert_eq!(list_array.data_type().to_string(), "failed to cast to");
2164+
let result = as_large_list_array(&list_array);
2165+
println!("{:?}", result);
2166+
assert_eq!(
2167+
result
2168+
.value(0)
2169+
.as_any()
2170+
.downcast_ref::<Int64Array>()
2171+
.unwrap()
2172+
.len(),
2173+
i32::MAX as usize + 10
2174+
);
21652175
}
21662176

21672177
#[test]
@@ -2929,13 +2939,13 @@ mod tests {
29292939
assert_eq!(result, &UInt64Array::from_value(4, 1));
29302940

29312941
// for LargeList
2932-
// array_length([1, 2, 3, 4], 2) = 4
2942+
let list_array = return_large_array();
29332943
let array = array_length(&[list_array, Arc::new(Int64Array::from_value(1, 1))])
29342944
.expect("failed to initialize function array_ndims");
29352945
let result =
29362946
as_uint64_array(&array).expect("failed to initialize function array_ndims");
29372947

2938-
assert_eq!(result, &UInt64Array::from_value(4, 1));
2948+
assert_eq!(result, &UInt64Array::from_value(i32::MAX as u64 + 10, 1));
29392949
}
29402950

29412951
#[test]
@@ -3071,23 +3081,10 @@ mod tests {
30713081
}
30723082

30733083
fn return_large_array() -> ArrayRef {
3074-
// Returns: [1, 2, 3, 4]
3084+
// Returns: [1, 1, ..., 1] (i32::MAX + 10 times)
30753085
let capacity = i32::MAX as usize + 10;
30763086
let args = vec![Arc::new(Int64Array::from(vec![Some(1)])) as ArrayRef; capacity];
30773087

3078-
println!("args.len() = {}", args.len());
3079-
3080-
make_array(&args).expect("failed to initialize function array")
3081-
}
3082-
3083-
fn return_extra_array() -> ArrayRef {
3084-
// Returns: [11, 12, 13, 14]
3085-
let args = [
3086-
Arc::new(Int64Array::from(vec![Some(11)])) as ArrayRef,
3087-
Arc::new(Int64Array::from(vec![Some(12)])) as ArrayRef,
3088-
Arc::new(Int64Array::from(vec![Some(13)])) as ArrayRef,
3089-
Arc::new(Int64Array::from(vec![Some(14)])) as ArrayRef,
3090-
];
30913088
make_array(&args).expect("failed to initialize function array")
30923089
}
30933090

0 commit comments

Comments
 (0)