(args: &[ArrayRef])
| 345 | } |
| 346 | |
| 347 | pub 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 | |
| 384 | fn concat_internal<O: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> { |
| 385 | let args = align_array_dimensions::<O>(args.to_vec())?; |
no test coverage detected
searching dependent graphs…