You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/11/29 04:19:40 UTC

[GitHub] [calcite] beyond1920 commented on a change in pull request #2612: [CALCITE-4888] Unify type inferring logical for Sarg RexLiteral

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



##########
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:
       `leastRestrictive => least restrictive`
   The exception message is keep consistent with `RexSargBuilder#RexSargBuilder` in `RexSimplify`.
   I think it's a better user experience for user. 




-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org