This is an automated email from the ASF dual-hosted git repository.

mbudiu 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 89da1b3a77 [CALCITE-7293] MAP constructor cannot handle VARIANT values 
that need casts
89da1b3a77 is described below

commit 89da1b3a77f79d6c67b7d707959c28c824140dfe
Author: Mihai Budiu <[email protected]>
AuthorDate: Sat Nov 15 15:50:59 2025 -0800

    [CALCITE-7293] MAP constructor cannot handle VARIANT values that need casts
    
    Signed-off-by: Mihai Budiu <[email protected]>
---
 core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java  | 3 ++-
 core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java 
b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
index 122708a41b..2808c89514 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
@@ -2045,7 +2045,8 @@ public static boolean isAtomic(RelDataType type) {
         || SqlTypeUtil.isNumeric(type)
         || SqlTypeUtil.isString(type)
         || SqlTypeUtil.isBoolean(type)
-        || typeName == SqlTypeName.UUID;
+        || typeName == SqlTypeName.UUID
+        || typeName == SqlTypeName.VARIANT;
   }
 
   /** Returns a DECIMAL type with the maximum precision for the current
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 a4b1dc79ad..129261c9e9 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -1516,6 +1516,10 @@ void testLikeAndSimilarFails() {
         .columnType("VARIANT NOT NULL ARRAY NOT NULL");
     expr("cast(MAP['a','b','c','d'] AS MAP<VARCHAR, VARIANT>)")
         .columnType("(VARCHAR NOT NULL, VARIANT) MAP NOT NULL");
+    // Test case for [CALCITE-7293] 
https://issues.apache.org/jira/browse/CALCITE-7293
+    // MAP constructor cannot handle VARIANT values that need casts
+    expr("MAP['a', CAST('x' AS VARIANT), 'b', CAST(NULL AS VARIANT)]")
+        .columnType("(CHAR(1) NOT NULL, VARIANT) MAP NOT NULL");
   }
 
   @Test void testAccessVariant() {

Reply via email to