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

zstan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 706c0b2af1 IGNITE-18559 Sql. Investigate the least restrictive type 
between VARCHAR and DECIMAL (#3797)
706c0b2af1 is described below

commit 706c0b2af163d096455a85d0246e10e6ba1c746c
Author: Evgeniy Stanilovskiy <[email protected]>
AuthorDate: Fri May 24 08:45:54 2024 +0300

    IGNITE-18559 Sql. Investigate the least restrictive type between VARCHAR 
and DECIMAL (#3797)
---
 .../ignite/internal/sql/engine/ItSqlOperatorsTest.java      |  9 ++++++++-
 .../internal/sql/engine/prepare/TypeCoercionTest.java       | 13 +------------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItSqlOperatorsTest.java
 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItSqlOperatorsTest.java
index 984bc94d35..f55e17b71b 100644
--- 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItSqlOperatorsTest.java
+++ 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItSqlOperatorsTest.java
@@ -279,7 +279,6 @@ public class ItSqlOperatorsTest extends 
BaseSqlIntegrationTest {
         assertExpression("'1'::INT").returns(1).check();
         assertExpression("COALESCE(null, 'a', 'A')").returns("a").check();
         assertExpression("NVL(null, 'a')").returns("a").check();
-        assertExpression("NULLIF(1, 2)").returns(1).check();
         assertExpression("CASE WHEN 1=1 THEN 1 ELSE 2 END").returns(1).check();
         assertExpression("DECODE(1, 1, 1, 2)").returns(1).check();
         assertExpression("LEAST('a', 'b')").returns("a").check();
@@ -337,6 +336,14 @@ public class ItSqlOperatorsTest extends 
BaseSqlIntegrationTest {
         assertExpression("'1' IS NOT JSON SCALAR").returns(false).check();
     }
 
+    @Test
+    public void testNullIf() {
+        assertExpression("NULLIF(1, 2)").returns(1).check();
+        assertExpression("NULLIF(1, 1)").returns(null).check();
+        assertThrowsSqlException(Sql.RUNTIME_ERR, "Character b is neither a 
decimal digit number, "
+                        + "decimal point, nor \"e\" notation exponential 
mark", () -> sql("SELECT NULLIF(12.2, 'b')"));
+    }
+
     @Test
     public void testFormatJson() {
         // TODO https://issues.apache.org/jira/browse/IGNITE-20163 Convert 
these tests to ones that do not expect errors
diff --git 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/TypeCoercionTest.java
 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/TypeCoercionTest.java
index 8a96b91058..83420d0041 100644
--- 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/TypeCoercionTest.java
+++ 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/TypeCoercionTest.java
@@ -79,7 +79,6 @@ import 
org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory;
 import org.apache.ignite.internal.sql.engine.type.UuidType;
 import org.apache.ignite.internal.tostring.S;
 import org.jetbrains.annotations.Nullable;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
@@ -135,8 +134,6 @@ public class TypeCoercionTest extends AbstractPlannerTest {
 
         for (RelDataType type : NUMERIC_TYPES) {
             if (type.getSqlTypeName() == SqlTypeName.DECIMAL) {
-                // TODO: https://issues.apache.org/jira/browse/IGNITE-18559
-                // Coerce to the widest decimal possible?
                 numericRules.add(typeCoercionRule(type, VARCHAR, new 
ToSpecificType(expectedDecimalType)));
                 numericRules.add(typeCoercionRule(VARCHAR, type, new 
ToSpecificType(expectedDecimalType)));
             } else {
@@ -249,6 +246,7 @@ public class TypeCoercionTest extends AbstractPlannerTest {
             "COALESCE(2, COALESCE('b', 2))",
             "COALESCE(2, COALESCE(2, 'b'))",
             "COALESCE('b', COALESCE(2, 3))",
+            "CASE WHEN 1=1 THEN 12.2 ELSE 'b' END",
     })
     public void testCaseWhenExpressionWithMixedTypesIsRejected(String expr) {
         checkExprResultFails(expr, "Illegal mixing of types in CASE or 
COALESCE statement");
@@ -260,15 +258,6 @@ public class TypeCoercionTest extends AbstractPlannerTest {
         checkExprResult("NULLIF(12.2, 2)", nullable(decimal));
     }
 
-    /**
-     * SQL 2016, clause 9.5: Mixing types in CASE/COALESCE expressions is 
illegal.
-     */
-    @Test
-    @Disabled("https://issues.apache.org/jira/browse/IGNITE-18559";)
-    public void testNullIfWithMixedTypesIsRejected() {
-        checkExprResultFails("NULLIF(12.2, 'b')", "Illegal mixing of types in 
CASE or COALESCE statement");
-    }
-
     @ParameterizedTest
     @MethodSource("varcharToUuid")
     public void testTypeCoercionBetweenUuidAndVarchar(TypeCoercionRule rule) {

Reply via email to