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

Zoltan Haindrich edited comment on CALCITE-4118 at 7/11/20, 11:13 AM:
----------------------------------------------------------------------

I forgot to make a note here: yesterday I started looking into this - I wrote a 
{{RexProgramTest}} testcase - which have cleared {{RexSimplify}} and I think I 
also checked {{ReduceExpressionRule}} - I believe the issue might be in 
somewhere the SqlToRelConverter; but I had to jump on something...
I'll try to get back to this on monday...and trace the full path of this issue.


was (Author: kgyrtkirk):
I forgot to make a note here: yesterday I started looking into this - I wrote a 
{{RexProgramTest}} testcase - which have cleared {{RexSimplify}} and I think I 
also checked {{ReduceExpressionRule}} - I believe the issue might be in 
somewhere the SqlToRelConverter; but I had to jump on something...

> 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)

Reply via email to