You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Shuo Cheng (Jira)" <ji...@apache.org> on 2020/07/10 04:10:00 UTC
[jira] [Commented] (CALCITE-4118) RexSimplify might remove CAST
from RexNode incorrectly
[ https://issues.apache.org/jira/browse/CALCITE-4118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17155086#comment-17155086 ]
Shuo Cheng commented on CALCITE-4118:
-------------------------------------
[~kgyrtkirk], please have a look. There is a approximate PR before, [CALCITE-3979|https://issues.apache.org/jira/browse/CALCITE-3979]
> 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
> Reporter: Shuo Cheng
> Priority: Major
> Fix For: 1.24.0
>
>
> {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)