You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Vladimir Steshin (Jira)" <ji...@apache.org> on 2024/10/11 18:02:00 UTC

[jira] [Created] (IGNITE-23414) Calcite. Fix cast of dynamic parameters by `::`.

Vladimir Steshin created IGNITE-23414:
-----------------------------------------

             Summary: Calcite. Fix cast of dynamic parameters by `::`.
                 Key: IGNITE-23414
                 URL: https://issues.apache.org/jira/browse/IGNITE-23414
             Project: Ignite
          Issue Type: Improvement
            Reporter: Vladimir Steshin


Dynamic parameters aren't casted like literals by `::`.

Reproducer:
{code:java}
sql("CREATE TABLE t(id integer primary key, int_col integer)");
        sql("insert into t values (1, 1)");

        // OK
        assertQuery("SELECT id from t where int_col=CAST('1' as TINYINT)").returns(1).check();
        assertQuery("SELECT id from t where int_col=CAST(1 as TINYINT)").returns(1).check();

        // OK
        assertThrows("SELECT id from t where int_col=CAST(11111 as TINYINT)", ArithmeticException.class, "overflow");
        assertThrows("SELECT id from t where int_col=CAST('11111' as TINYINT)", ArithmeticException.class, "overflow");
        assertThrows("SELECT id from t where int_col=11111::TINYINT", ArithmeticException.class, "overflow");
        assertThrows("SELECT id from t where int_col='11111'::TINYINT", ArithmeticException.class, "overflow");

        // Fails
        assertThrows("SELECT id from t where int_col=CAST(? as TINYINT)", ArithmeticException.class, "overflow", 1111);
        assertThrows("SELECT id from t where int_col=CAST(? as TINYINT)", ArithmeticException.class, "overflow", "1111");
        assertThrows("SELECT id from t where int_col=?::TINYINT", ArithmeticException.class, "overflow", 1111);
        assertThrows("SELECT id from t where int_col=?::TINYINT", ArithmeticException.class, "overflow", "1111");

        // Fails
        assertQuery("SELECT id from t where int_col=CAST(? as TINYINT)").withParams('1').returns(1).check();
        assertQuery("SELECT id from t where int_col=CAST(? as INTEGER)").withParams('1').returns(1).check();
{code}




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