Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.23.0, 1.24.0
Description
@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(); }
Consider the above test case, we get the following plan after SqlToRel.
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]])
As it is shown, `cast(* as varchar)` is removed (by RexSimplify#SimplifyCast), which is obviously wrong, because BIGINT can not cast to VARBINARY.
Attachments
Issue Links
- is caused by
-
CALCITE-3712 Optimize lossless casts in RexSimplify: CAST(CAST(intExpr as BIGINT) as INT) => intExpr
-
- Closed
-
- is related to
-
CALCITE-3979 Simplification might have removed CAST expression(s) incorrectly
-
- Closed
-
- relates to
-
CALCITE-4081 Round-tripping a DECIMAL literal through Planner -> RelToSqlConverter -> Planner throws validation error
-
- Closed
-
- links to