Skip to content

Commit

Permalink
internal as vec
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-isaacs committed Nov 22, 2024
1 parent 5b04445 commit 40b1860
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions datafusion/functions/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ pub mod test {
let expected: Result<Option<$EXPECTED_TYPE>> = $EXPECTED;
let func = $FUNC;

let args_vec = $ARGS.iter().cloned().collect::<Vec<_>>();

let type_array = $ARGS.iter().map(|arg| arg.data_type()).collect::<Vec<_>>();
let cardinality = $ARGS
.iter()
Expand All @@ -149,7 +151,7 @@ pub mod test {
let return_type = return_type.unwrap();
assert_eq!(return_type, $EXPECTED_DATA_TYPE);

let result = func.invoke_with_args(datafusion_expr::ScalarFunctionArgs{args: $ARGS, number_rows: cardinality, return_type: &return_type});
let result = func.invoke_with_args(datafusion_expr::ScalarFunctionArgs{args: args_vec, number_rows: cardinality, return_type: &return_type});
assert_eq!(result.is_ok(), true, "function returned an error: {}", result.unwrap_err());

let result = result.unwrap().clone().into_array(cardinality).expect("Failed to convert to array");
Expand All @@ -170,7 +172,7 @@ pub mod test {
}
else {
// invoke is expected error - cannot use .expect_err() due to Debug not being implemented
match func.invoke_with_args(datafusion_expr::ScalarFunctionArgs{args: $ARGS, number_rows: cardinality, return_type: &return_type.unwrap()}) {
match func.invoke_with_args(datafusion_expr::ScalarFunctionArgs{args: args_vec, number_rows: cardinality, return_type: &return_type.unwrap()}) {
Ok(_) => assert!(false, "expected error"),
Err(error) => {
assert!(expected_error.strip_backtrace().starts_with(&error.strip_backtrace()));
Expand Down

0 comments on commit 40b1860

Please sign in to comment.