libenchao commented on code in PR #2853:
URL: https://github.com/apache/calcite/pull/2853#discussion_r990619993


##########
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:
   The question is: "is it correct to use `ranges.get(0).getType()`?". If it's 
not correct, then we'd better throw exception. If we decide to keep it, then we 
should know in what cases will `searchType == null` is true, and we still want 
to use `ranges.get(0).getType()` as the final type.



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