Skip to content

Commit d8029cb

Browse files
committed
feat: support literal for ARRAY top level
1 parent eb5f2bf commit d8029cb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

native/spark-expr/src/conversion_funcs/cast.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::utils::array_with_timezone;
2020
use crate::{EvalMode, SparkError, SparkResult};
2121
use arrow::array::builder::StringBuilder;
2222
use arrow::array::{DictionaryArray, StringArray, StructArray};
23+
use arrow::compute::can_cast_types;
2324
use arrow::datatypes::{DataType, Schema};
2425
use arrow::{
2526
array::{
@@ -967,6 +968,9 @@ fn cast_array(
967968
to_type,
968969
cast_options,
969970
)?),
971+
(List(_), List(_)) if can_cast_types(from_type, to_type) => {
972+
Ok(cast_with_options(&array, to_type, &CAST_OPTIONS)?)
973+
}
970974
(UInt8 | UInt16 | UInt32 | UInt64, Int8 | Int16 | Int32 | Int64)
971975
if cast_options.allow_cast_unsigned_ints =>
972976
{

spark/src/main/scala/org/apache/comet/expressions/CometCast.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ object CometCast {
6363

6464
(fromType, toType) match {
6565
case (dt: ArrayType, _: ArrayType) if dt.elementType == NullType => Compatible()
66+
case (dt: ArrayType, dt1: ArrayType) =>
67+
isSupported(dt.elementType, dt1.elementType, timeZoneId, evalMode)
6668
case (dt: DataType, _) if dt.typeName == "timestamp_ntz" =>
6769
// https://github.com/apache/datafusion-comet/issues/378
6870
toType match {

0 commit comments

Comments
 (0)