Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Nov 14, 2023
1 parent bdba08a commit 91612a4
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions datafusion/physical-expr/src/array_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,17 @@ mod tests {
#[test]
fn test_return_large_array() {
let list_array = return_large_array();
assert_eq!(list_array.data_type().to_string(), "failed to cast to");
let result = as_large_list_array(&list_array);
println!("{:?}", result);
assert_eq!(
result
.value(0)
.as_any()
.downcast_ref::<Int64Array>()
.unwrap()
.len(),
i32::MAX as usize + 10
);
}

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

// for LargeList
// array_length([1, 2, 3, 4], 2) = 4
let list_array = return_large_array();
let array = array_length(&[list_array, Arc::new(Int64Array::from_value(1, 1))])
.expect("failed to initialize function array_ndims");
let result =
as_uint64_array(&array).expect("failed to initialize function array_ndims");

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

#[test]
Expand Down Expand Up @@ -3071,23 +3081,10 @@ mod tests {
}

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

println!("args.len() = {}", args.len());

make_array(&args).expect("failed to initialize function array")
}

fn return_extra_array() -> ArrayRef {
// Returns: [11, 12, 13, 14]
let args = [
Arc::new(Int64Array::from(vec![Some(11)])) as ArrayRef,
Arc::new(Int64Array::from(vec![Some(12)])) as ArrayRef,
Arc::new(Int64Array::from(vec![Some(13)])) as ArrayRef,
Arc::new(Int64Array::from(vec![Some(14)])) as ArrayRef,
];
make_array(&args).expect("failed to initialize function array")
}

Expand Down

0 comments on commit 91612a4

Please sign in to comment.