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_r314588864
 
 

 ##########
 File path: 
api/src/main/java/org/apache/iceberg/expressions/UnboundPredicate.java
 ##########
 @@ -125,13 +154,38 @@ 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 = literalSet().stream().map(
+        val -> {
+          if (val instanceof LiteralSet.CharSeqWrapper) {
+            val = (T) ((LiteralSet.CharSeqWrapper) val).unWrap();
+          }
+          Literal<T> lit = Literals.from(val).to(field.type());
+          if (lit == null) {
+            throw new ValidationException(String.format(
+                "Invalid value for comparison inclusive type %s: %s (%s)",
+                field.type(), val, val.getClass().getName()));
+          }
+          return lit;
+        })
+        .filter(l -> l != Literals.aboveMax() && l != Literals.belowMin())
+        .collect(Collectors.toSet());
 
 Review comment:
   @rdblue The main reason to make it to be a `Set` is for deduplication.
   For example,
   ```
   StructType struct = StructType.of(required(15, "d", Types.DecimalType.of(9, 
2)));
   UnboundPredicate<Double> unbound = Expressions.in("d", 12.40, 12.401, 
12.402);
   Expression expr = unbound.bind(struct);
   // expr should be `BoundPredicate<BigDecimal>` with `EQ` op.
   ```
   So here, the size of literalSet might shrink due to the type conversion.
   

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