Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions datafusion/spark/src/function/array/spark_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use arrow::array::{
MutableArrayData, NullArray, OffsetSizeTrait,
};
use arrow::buffer::OffsetBuffer;
use arrow::datatypes::{DataType, Field, FieldRef};
use arrow::datatypes::{DataType, Field};
use datafusion_common::utils::SingleRowListArrayBuilder;
use datafusion_common::{plan_datafusion_err, plan_err, Result};
use datafusion_expr::type_coercion::binary::comparison_coercion;
use datafusion_expr::{
ColumnarValue, ReturnFieldArgs, ScalarFunctionArgs, ScalarUDFImpl, Signature,
ColumnarValue,ScalarFunctionArgs, ScalarUDFImpl, Signature,
TypeSignature, Volatility,
};

Expand Down Expand Up @@ -92,21 +92,6 @@ impl ScalarUDFImpl for SparkArray {
))))
}

fn return_field_from_args(&self, args: ReturnFieldArgs) -> Result<FieldRef> {
let data_types = args
.arg_fields
.iter()
.map(|f| f.data_type())
.cloned()
.collect::<Vec<_>>();
let return_type = self.return_type(&data_types)?;
Ok(Arc::new(Field::new(
"this_field_name_is_irrelevant",
return_type,
false,
)))
}

fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
let ScalarFunctionArgs { args, .. } = args;
make_scalar_function(make_array_inner)(args.as_slice())
Expand Down Expand Up @@ -166,7 +151,6 @@ pub fn make_array_inner(arrays: &[ArrayRef]) -> Result<ArrayRef> {
.build_list_array(),
))
}
DataType::LargeList(..) => array_array::<i64>(arrays, data_type),
_ => array_array::<i32>(arrays, data_type),
}
}
Expand Down
15 changes: 15 additions & 0 deletions datafusion/sqllogictest/test_files/spark/array/array.slt
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,18 @@ query ?
SELECT array(array(1,2));
----
[[1, 2]]

query ?
SELECT array(arrow_cast(array(1), 'LargeList(Int64)'));
----
[[1]]

query ?
SELECT array(arrow_cast(array(1), 'LargeList(Int64)'), arrow_cast(array(), 'LargeList(Int64)'));
----
[[1], []]

query ?
SELECT array(arrow_cast(array(1,2), 'LargeList(Int64)'), array(3));
----
[[1, 2], [3]]