[ 
https://issues.apache.org/jira/browse/IGNITE-18762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maksim Zhuravkov updated IGNITE-18762:
--------------------------------------
    Description: In some case   (was: 
{code:java}
@Disabled
@Test
public void testCaseWhenExprNonBooleanAtBooleanOnlyPosition() {
    // This query should be rejected since the first parameter is a string
    // but the position it appears to be allows only BOOLEAN arguments.

    sql("SELECT CASE ? WHEN c1 = '1' THEN 0 ELSE 1 END FROM (VALUES ('1')) 
t(c1);", '1');
    // PostgreSQL reject such query with the following error:
    /*
    org.postgresql.util.PSQLException: ERROR: operator does not exist: 
character varying = boolean
    Hint: No operator matches the given name and argument types. You might need 
to add explicit type casts.
    Position: 16
     */

    // Current implementation produces:
    /*
    class org.apache.calcite.sql.SqlBasicCall: CAST(`T`.`C1` AS UNKNOWN)
        java.lang.UnsupportedOperationException: class 
org.apache.calcite.sql.SqlBasicCall: CAST(`T`.`C1` AS UNKNOWN)
            at org.apache.calcite.util.Util.needToImplement(Util.java:1101)
            at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getValidatedNodeType(SqlValidatorImpl.java:1767)
            at 
org.apache.calcite.sql.SqlBinaryOperator.convertType(SqlBinaryOperator.java:137)
            at 
org.apache.calcite.sql.SqlBinaryOperator.adjustType(SqlBinaryOperator.java:132)
     */
}

@Disabled
// CASE WHEN
// Invalid Expression type
@Test
public void testCaseWhenExpr() {
    // must return 0<text> but returns <0><int>
    assertQuery("SELECT CASE c1 WHEN '2' THEN '1' ELSE '0' END FROM (VALUES(1)) 
t(c1)").returns('0').check();
    assertQuery("SELECT CASE c1 WHEN '2' THEN '1' ELSE '0' END FROM (VALUES(2)) 
t(c1)").returns('1').check();

    // must be rejected
    assertQuery("SELECT CASE c1 WHEN '2' THEN '1' ELSE '0' END FROM 
(VALUES('1')) t(c1)").returns('0').check();
}
// Invalid type of CASE expression
{code}
)

> Sql. Incorrect types can be inferred for CASE  WHEN .. END expressions
> ----------------------------------------------------------------------
>
>                 Key: IGNITE-18762
>                 URL: https://issues.apache.org/jira/browse/IGNITE-18762
>             Project: Ignite
>          Issue Type: Improvement
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: calcite2-required, calcite3-required, ignite-3
>
> In some case 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to