Invoke a two-argument list UDF with the given arrays and assert the boolean output matches `expected`.
(
udf: &dyn ScalarUDFImpl,
haystack: &ArrayRef,
needle: ArrayRef,
expected: &[Option<bool>],
)
| 1207 | /// Invoke a two-argument list UDF with the given arrays and assert the |
| 1208 | /// boolean output matches `expected`. |
| 1209 | fn invoke_and_assert( |
| 1210 | udf: &dyn ScalarUDFImpl, |
| 1211 | haystack: &ArrayRef, |
| 1212 | needle: ArrayRef, |
| 1213 | expected: &[Option<bool>], |
| 1214 | ) { |
| 1215 | let num_rows = haystack.len(); |
| 1216 | let list_type = haystack.data_type(); |
| 1217 | let result = udf |
| 1218 | .invoke_with_args(ScalarFunctionArgs { |
| 1219 | args: vec![ |
| 1220 | ColumnarValue::Array(Arc::clone(haystack)), |
| 1221 | ColumnarValue::Array(needle), |
| 1222 | ], |
| 1223 | arg_fields: vec![ |
| 1224 | Arc::new(Field::new("haystack", list_type.clone(), false)), |
| 1225 | Arc::new(Field::new("needle", list_type.clone(), false)), |
| 1226 | ], |
| 1227 | number_rows: num_rows, |
| 1228 | return_field: Arc::new(Field::new("return", DataType::Boolean, true)), |
| 1229 | config_options: Arc::new(ConfigOptions::default()), |
| 1230 | }) |
| 1231 | .unwrap(); |
| 1232 | let output = result.into_array(num_rows).unwrap(); |
| 1233 | assert_eq!(output.as_boolean().iter().collect::<Vec<_>>(), expected); |
| 1234 | } |
| 1235 | |
| 1236 | #[test] |
| 1237 | fn test_sliced_list_offsets() { |
searching dependent graphs…