beyond1920 commented on a change in pull request #2612:
URL: https://github.com/apache/calcite/pull/2612#discussion_r758032877



##########
File path: core/src/main/java/org/apache/calcite/rex/RexBuilder.java
##########
@@ -1332,10 +1334,14 @@ public RexNode makeIn(RexNode arg, List<? extends 
RexNode> ranges) {
     if (areAssignable(arg, ranges)) {
       final Sarg sarg = toSarg(Comparable.class, ranges, RexUnknownAs.UNKNOWN);
       if (sarg != null) {
-        final RexNode range0 = ranges.get(0);
+        final List<RelDataType> types = Util.transform(ranges, 
RexNode::getType);
+        final List<RelDataType> distinctTypes = Util.distinctList(types);
+        final RelDataType sargType = requireNonNull(
+            typeFactory.leastRestrictive(distinctTypes),
+            () -> "Can't find leastRestrictive type among " + distinctTypes);
         return makeCall(SqlStdOperatorTable.SEARCH,
             arg,

Review comment:
       > It seems that the code does some logic for implicit type coercion here
   
   The pr does not aim to fix implicit type coercion, it only want to solve the 
behavior of `RexBulder#makeIn` if the arguments are compatibule, just like 
discussion in the JIRA:
   
![image](https://user-images.githubusercontent.com/1525333/143808516-287f6065-f46d-479a-a897-abf5b4639aea.png).
   I could create another JIRA to solve implicit type coercion.
   Let's solve the problem one by one.
   
   > Before the change, the in-compatible values in IN clause does not throw 
while with this patch it does, we need to confirm the behavior.
   
   The old behavior is not correct which we need to fix.
   
   
   




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