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

Function array_concat_inner

datafusion/functions-nested/src/concat.rs:347–382  ·  view source on GitHub ↗
(args: &[ArrayRef])

Source from the content-addressed store, hash-verified

345}
346
347pub fn array_concat_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
348 if args.is_empty() {
349 return exec_err!("array_concat expects at least one argument");
350 }
351
352 let mut all_null = true;
353 let mut large_list = false;
354 for arg in args {
355 match arg.data_type() {
356 DataType::Null => continue,
357 DataType::LargeList(_) => large_list = true,
358 _ => (),
359 }
360 if arg.null_count() < arg.len() {
361 all_null = false;
362 }
363 }
364
365 if all_null {
366 // Return a null array with the same type as the first non-null-type argument
367 let return_type = args
368 .iter()
369 .map(|arg| arg.data_type())
370 .find_or_first(|d| !d.is_null())
371 .unwrap(); // Safe because args is non-empty
372
373 Ok(arrow::array::make_array(ArrayData::new_null(
374 return_type,
375 args[0].len(),
376 )))
377 } else if large_list {
378 concat_internal::<i64>(args)
379 } else {
380 concat_internal::<i32>(args)
381 }
382}
383
384fn concat_internal<O: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
385 let args = align_array_dimensions::<O>(args.to_vec())?;

Callers 1

criterion_benchmarkFunction · 0.85

Calls 8

make_arrayFunction · 0.85
null_countMethod · 0.80
is_emptyMethod · 0.45
data_typeMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…