jun-he commented on a change in pull request #357: Add in and not in predicates
URL: https://github.com/apache/incubator-iceberg/pull/357#discussion_r318402641
 
 

 ##########
 File path: 
api/src/main/java/org/apache/iceberg/expressions/UnboundPredicate.java
 ##########
 @@ -125,13 +149,40 @@ public Expression bind(Types.StructType struct, boolean 
caseSensitive) {
         case LT_EQ:
         case EQ:
           return Expressions.alwaysFalse();
-//        case IN:
-//          break;
-//        case NOT_IN:
-//          break;
       }
     }
     return new BoundPredicate<>(op(), new BoundReference<>(field.fieldId(),
-        schema.accessorForField(field.fieldId())), lit);
+            schema.accessorForField(field.fieldId())), lit);
+  }
+
+  @SuppressWarnings("unchecked")
+  private Expression bindInOperation(Types.NestedField field, Schema schema) {
+    final Set<Literal<T>> lits = literals().stream().map(
+        l -> {
+          Literal<T> lit = l.to(field.type());
+          if (lit == null) {
+            throw new ValidationException(String.format(
+                "Invalid value for comparison inclusive type %s: %s (%s)",
+                field.type(), l.value(), l.value().getClass().getName()));
+          }
+          return lit;
+        })
+        .filter(l -> l != Literals.aboveMax() && l != Literals.belowMin())
+        .collect(Collectors.toSet());
+
+    if (lits.isEmpty()) {
+      return Expressions.alwaysFalse();
+    } else if (lits.size() == 1) {
+      return new BoundPredicate<>(Operation.EQ, new 
BoundReference<>(field.fieldId(),
+          schema.accessorForField(field.fieldId())), lits.iterator().next());
 
 Review comment:
   👌 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to