This is an automated email from the ASF dual-hosted git repository. rubenql pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push: new 3843ede3d2 [CALCITE-5674] CAST expr to target type should respect nullable when it is complex type (follow-up) 3843ede3d2 is described below commit 3843ede3d28783235780c0f81f725dc7e64a7828 Author: rubenada <rube...@gmail.com> AuthorDate: Wed May 24 14:02:06 2023 +0100 [CALCITE-5674] CAST expr to target type should respect nullable when it is complex type (follow-up) --- core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java | 2 +- core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java index ddc30ab295..81da37c7e7 100644 --- a/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java +++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java @@ -147,7 +147,7 @@ public class SqlCastFunction extends SqlFunction { RelDataType newElementType = createTypeWithNullabilityFromExpr( typeFactory, expressionElementType, targetElementType, safe); - return isArray(expressionType) + return isArray(targetType) ? SqlTypeUtil.createArrayType(typeFactory, newElementType, isNullable) : SqlTypeUtil.createMultisetType(typeFactory, newElementType, isNullable); } diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java index e58c7b29df..19b2b6a2d7 100644 --- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java +++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java @@ -6990,6 +6990,8 @@ public class SqlValidatorTest extends SqlValidatorTestCase { .columnType("VARCHAR(5) ARRAY NOT NULL"); sql("select cast(multiset[1,null,2] as int multiset) from (values (1))") .columnType("INTEGER MULTISET NOT NULL"); + sql("select cast(array[1,null,2] as int multiset) from (values (1))") + .columnType("INTEGER MULTISET NOT NULL"); // test array type. sql("select cast(\"intArrayType\" as int array) from COMPLEXTYPES.CTC_T1")