You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Andrei Sereda (Jira)" <ji...@apache.org> on 2020/08/22 18:49:03 UTC

[jira] [Closed] (CALCITE-4118) RexSimplify might remove CAST from RexNode incorrectly

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

Andrei Sereda closed CALCITE-4118.
----------------------------------

Released as part of 1.25 ([68b02dfd4af15bc|https://github.com/apache/calcite/commit/68b02dfd4af15bc94a91a0cd2a30655d04439555])

> RexSimplify might remove CAST from RexNode incorrectly
> ------------------------------------------------------
>
>                 Key: CALCITE-4118
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4118
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.23.0, 1.24.0
>            Reporter: Shuo Cheng
>            Assignee: Chunwei Lei
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.25.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> {code:java}
> @Test void testCastError() {
>   final String sql = "select cast(cast(count(distinct empno) as varchar(65536)) as varbinary)\n"
>       + "from emp group by deptno";
>   sql(sql).ok();
> }
> {code}
> Consider the above test case, we get the following plan after SqlToRel.
> {code:java}
> LogicalProject(EXPR$0=[CAST($1):VARBINARY NOT NULL])
>       LogicalAggregate(group=[{0}], agg#0=[COUNT(DISTINCT $1)])
>         LogicalProject(DEPTNO=[$7], EMPNO=[$0])
>           LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> As it is shown, `cast(* as varchar)` is removed (by RexSimplify#SimplifyCast), which is obviously wrong, because BIGINT can not cast to VARBINARY.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)