abhishek-das-gupta commented on code in PR #2853:
URL: https://github.com/apache/calcite/pull/2853#discussion_r990811601


##########
core/src/main/java/org/apache/calcite/rex/RexBuilder.java:
##########
@@ -1355,10 +1356,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 = ranges.stream()
+            .map(RexNode::getType)
+            .collect(Collectors.toList());
+        RelDataType searchType = typeFactory.leastRestrictive(types);
+        searchType = searchType == null ? ranges.get(0).getType() : searchType;

Review Comment:
   Thanks @libenchao .  I think if we don't find a  least restrictive 
`searchType`  among the `types`, then selecting `ranges.get(0).getType()` is 
wrong.  Since it might eventually fail at Rel to Sql conversion.  Hence 
throwing an exception



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