NobiGo commented on code in PR #2811:
URL: https://github.com/apache/calcite/pull/2811#discussion_r1772468643


##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -1958,7 +1959,33 @@ private RelOptUtil.Exists convertExists(
       if (!values.getTuples().isEmpty()) {
         unionInputs.add(values);
       }
-      resultRel = LogicalUnion.create(unionInputs, true);
+      RelDataType finalRowType = rowType;

Review Comment:
   SqlToRelConverter is still required. Because it occurred during the 
conversion of IN list to Values.
   
   Before this PR. 
   
   The SQL:
   ```
   SELECT empno FROM emp AS e WHERE cast(e.empno as bigint) in (130, 131, 132, 
133, 134)
   ```
   The Calcite will convert it to :
   ```
   LogicalAggregate(group=[{0}])
     LogicalValues(tuples=[[{ 130 }, { 131 }, { 132 }, { 133 }, { 134 }]])
   ```
   But when we add CAST like:
   ```
   SELECT empno FROM emp AS e WHERE cast(e.empno as bigint) in (cast(130 as 
bigint), cast(131 as bigint), cast(132 as bigint), cast(133 as bigint), 
cast(134 as bigint))
   ````
   The Calcite will convert it to:
   ```
   LogicalUnion(all=[true])
     LogicalValues(tuples=[[{ 130 }]])
     LogicalValues(tuples=[[{ 131 }]])
     LogicalValues(tuples=[[{ 132 }]])
     LogicalValues(tuples=[[{ 133 }]])
     LogicalValues(tuples=[[{ 134 }]])
   ```
   This test case was not covered before. The change in this PR makes this bug 
apparent. Do we need a separate PR to resolve it first? I hope this can answer 
your question.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to