Skip to content

Commit

Permalink
return based on data_type in make_array
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Dec 2, 2023
1 parent 05e365a commit 6caf58f
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions datafusion/physical-expr/src/array_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ use datafusion_common::cast::{
as_generic_list_array, as_generic_string_array, as_int64_array, as_list_array,
as_null_array, as_string_array,
};
use datafusion_common::utils::{
array_into_large_list_array, array_into_list_array, list_ndims,
};
use datafusion_common::utils::{array_into_list_array, list_ndims};
use datafusion_common::{
exec_err, internal_err, not_impl_err, plan_err, DataFusionError, Result,
};
Expand Down Expand Up @@ -360,28 +358,14 @@ pub fn make_array(arrays: &[ArrayRef]) -> Result<ArrayRef> {
}
}

let len = arrays.len();
match data_type {
// Either an empty array or all nulls:
DataType::Null => {
let array = new_null_array(&DataType::Null, arrays.len());
if len <= i32::MAX as usize {
Ok(Arc::new(array_into_list_array(array)))
} else if len <= i64::MAX as usize {
Ok(Arc::new(array_into_large_list_array(array)))
} else {
exec_err!("The number of elements {} in the array exceed the maximum number of elements supported by DataFusion",len)
}
}
data_type => {
if len <= i32::MAX as usize {
array_array::<i32>(arrays, data_type)
} else if len <= i64::MAX as usize {
array_array::<i64>(arrays, data_type)
} else {
exec_err!("The number of elements {} in the array exceed the maximum number of elements supported by DataFusion",len)
}
Ok(Arc::new(array_into_list_array(array)))
}
DataType::LargeList(..) => array_array::<i64>(arrays, data_type),
_ => array_array::<i32>(arrays, data_type),
}
}

Expand Down

0 comments on commit 6caf58f

Please sign in to comment.