[ https://issues.apache.org/jira/browse/CALCITE-4118?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chunwei Lei resolved CALCITE-4118. ---------------------------------- Fix Version/s: 1.25.0 Resolution: Fixed Fixed inĀ [https://github.com/apache/calcite/commit/2088488ac8327b19512a76a122cae2961fc551c3]. > 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 > 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)