You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maksim Zhuravkov (Jira)" <ji...@apache.org> on 2023/05/30 14:17:01 UTC

[jira] [Comment Edited] (IGNITE-19481) Sql. Inconsistent behaviour of DML operations introduced by implicit type casts.

    [ https://issues.apache.org/jira/browse/IGNITE-19481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17727537#comment-17727537 ] 

Maksim Zhuravkov edited comment on IGNITE-19481 at 5/30/23 2:16 PM:
--------------------------------------------------------------------

Vanilla calcite (the latest main branch):

{code:java}
update "foo"."bar" set "name"=1, "salary"=2.0 WHERE "empid"=0
{code}
This query fails for another reason (it seems that there is a bug in EnumerableTableModify) - but it is clear from type information that resulting expression should include an update expression but it includes that expression w/o a type cast:

{code:java}
result = {RelRecordType@8016} "RecordType(JavaType(int) empid, JavaType(int) deptno, JavaType(class java.lang.String) name, JavaType(float) salary, JavaType(class java.lang.Integer) commission, INTEGER EXPR$0, DECIMAL(2, 1) EXPR$1)"

this = {EnumerableTableModify@8972} "rel#41:EnumerableTableModify.ENUMERABLE.[](input=EnumerableCalc#47,table=[foo, bar],operation=UPDATE,updateColumnList=[name, salary],sourceExpressionList=[CAST(1):VARCHAR NOT NULL, 2.0:REAL],flattened=false)"
{code}



was (Author: JIRAUSER298618):
Vanilla calcite (the latest main branch):

{code:java}
update "foo"."bar" set "name"=1, "salary"=2.0 WHERE "empid"=0
{code}

{code:java}
result = {RelRecordType@8016} "RecordType(JavaType(int) empid, JavaType(int) deptno, JavaType(class java.lang.String) name, JavaType(float) salary, JavaType(class java.lang.Integer) commission, INTEGER EXPR$0, DECIMAL(2, 1) EXPR$1)"

this = {EnumerableTableModify@8972} "rel#41:EnumerableTableModify.ENUMERABLE.[](input=EnumerableCalc#47,table=[foo, bar],operation=UPDATE,updateColumnList=[name, salary],sourceExpressionList=[CAST(1):VARCHAR NOT NULL, 2.0:REAL],flattened=false)"
{code}


> Sql. Inconsistent behaviour of DML operations introduced by implicit type casts.
> --------------------------------------------------------------------------------
>
>                 Key: IGNITE-19481
>                 URL: https://issues.apache.org/jira/browse/IGNITE-19481
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 3.0.0-beta1
>            Reporter: Maksim Zhuravkov
>            Assignee: Maksim Zhuravkov
>            Priority: Minor
>              Labels: calcite2-required, ignite-3
>
> INSERT:
> {code:java}
>    @Test
>     public void testInsertIntToStr() {
>         sql("CREATE TABLE t1(int_col INTEGER PRIMARY KEY, str_col VARCHAR)");
>         sql("INSERT INTO t1 VALUES(1, 2)");
>     }
> {code}
> Result: OK
> UPDATE:
> {code:java}
>   @Test
>     public void testUpdateIntToStr() {
>         sql("CREATE TABLE t1(int_col INTEGER PRIMARY KEY, str_col VARCHAR)");
>         sql("INSERT INTO t1 VALUES(1, '11111')");
>         sql("UPDATE t1 SET str_col=1");
>     }
> {code}
> Error:
> {code:java}
> TraceId:3b57d830-a327-4c77-89ec-a45a1411daf6 class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap')
> {code}



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