MCPcopy Create free account
hub / github.com/apache/datafusion / test_array_with_nulls

Function test_array_with_nulls

datafusion/functions/src/unicode/reverse.rs:239–290  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

237
238 #[test]
239 fn test_array_with_nulls() {
240 use crate::unicode::reverse::reverse;
241 use arrow::array::ArrayRef;
242 use std::sync::Arc;
243
244 let input_values = vec![Some("abcd"), None, Some("XYZ"), Some("héllo"), None];
245 let expected: Vec<Option<&str>> =
246 vec![Some("dcba"), None, Some("ZYX"), Some("olléh"), None];
247
248 let cases: Vec<(&str, ArrayRef)> = vec![
249 (
250 "StringArray",
251 Arc::new(StringArray::from(input_values.clone())),
252 ),
253 (
254 "LargeStringArray",
255 Arc::new(LargeStringArray::from(input_values.clone())),
256 ),
257 (
258 "StringViewArray",
259 Arc::new(StringViewArray::from(input_values.clone())),
260 ),
261 ];
262
263 for (label, input) in cases {
264 let out = reverse(&[input]).unwrap();
265 assert_eq!(out.len(), expected.len(), "{label}: length mismatch");
266
267 let actual: Vec<Option<&str>> = match out.data_type() {
268 Utf8 => out
269 .as_any()
270 .downcast_ref::<StringArray>()
271 .unwrap()
272 .iter()
273 .collect(),
274 LargeUtf8 => out
275 .as_any()
276 .downcast_ref::<LargeStringArray>()
277 .unwrap()
278 .iter()
279 .collect(),
280 Utf8View => out
281 .as_any()
282 .downcast_ref::<StringViewArray>()
283 .unwrap()
284 .iter()
285 .collect(),
286 other => panic!("{label}: unexpected output type {other:?}"),
287 };
288 assert_eq!(actual, expected, "{label}: value mismatch");
289 }
290 }
291}

Callers

nothing calls this directly

Calls 5

reverseFunction · 0.85
collectMethod · 0.80
data_typeMethod · 0.45
iterMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…