Skip to content

Commit

Permalink
support cast between NULL and FixedSizedLisr
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Jan 18, 2024
1 parent 5a6ab22 commit 78e7d2f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions datafusion/common/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2974,6 +2974,19 @@ impl TryFrom<&DataType> for ScalarValue {
.to_owned()
.into(),
),
// `ScalaValue::FixedSizeList` contains single element `FixedSizeList`.
DataType::FixedSizeList(field, _) => ScalarValue::FixedSizeList(
new_null_array(
&DataType::FixedSizeList(
Arc::new(Field::new("item", field.data_type().clone(), true)),
1,
),
1,
)
.as_fixed_size_list()
.to_owned()
.into(),
),
DataType::Struct(fields) => ScalarValue::Struct(None, fields.clone()),
DataType::Null => ScalarValue::Null,
_ => {
Expand Down
11 changes: 11 additions & 0 deletions datafusion/sqllogictest/test_files/arrow_typeof.slt
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ LargeList(Field { name: "item", data_type: LargeList(Field { name: "item", data_

## FixedSizeList

query ?
select arrow_cast(null, 'FixedSizeList(1, Int64)');
----
NULL

#TODO: arrow-rs doesn't support it yet
#query ?
#select arrow_cast('1', 'FixedSizeList(1, Int64)');
#----
#[1]

query error DataFusion error: Optimizer rule 'simplify_expressions' failed
select arrow_cast(make_array(1, 2, 3), 'FixedSizeList(4, Int64)');

Expand Down

0 comments on commit 78e7d2f

Please sign in to comment.