Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.30.0
Description
The SQL:
select * from dept where deptno + 20 in (select deptno from dept);
Calcite returns the wrong answer.
but the SQL
select * from dept where deptno + 20 in (select cast(deptno as integer) from dept);
Calcite returns the correct answer.
So when we generate the RelNode, we can add the type cast.
Before the type cast:
LogicalProject(DEPTNO=[$0], DNAME=[$1], LOC=[$2]) LogicalFilter(condition=[IN(+($0, 20), { LogicalProject(DEPTNO=[$0]) LogicalTableScan(table=[[scott, DEPT]]) })]) LogicalTableScan(table=[[scott, DEPT]])
After the type cast:
LogicalProject(DEPTNO=[$0], DNAME=[$1], LOC=[$2]) LogicalFilter(condition=[IN(+($0, 20), { LogicalProject(EXPR$0=[CAST($0):INTEGER NOT NULL]) LogicalTableScan(table=[[scott, DEPT]]) })]) LogicalTableScan(table=[[scott, DEPT]])
Same SQL includes:
select * from dept where deptno in (select sal-780 from emp)
Attachments
Issue Links
- is blocked by
-
CALCITE-6592 Add test for RelMdPredicates pull up predicate from UNION when it's input predicates include NULL VALUE
- Resolved
- is duplicated by
-
CALCITE-5930 When sqlToRel is converted from in to join, condition '=' on both sides will have inconsistent data types.
- Closed
- is related to
-
CALCITE-5769 Optimizing 'CAST(e AS t) IS NOT NULL' to 'e IS NOT NULL'
- Closed
-
CALCITE-2302 Implicit type cast support
- Closed
- relates to
-
CALCITE-5743 Query gives incorrect result when COUNT appears in the correlated subquery select list
- Open
-
CALCITE-5210 "type mismatch" litmus test failure during during SqlToRelConverter for group-by on `case` having `in` expression predicates exceeding SqlRelConverter.Config InSubQueryThreshold with nullable left-hand-side
- Closed
-
CALCITE-6435 SqlToRel conversion of IN expressions may lead to incorrect simplifications
- Closed
- links to