rdblue commented on a change in pull request #628: Implement the project and 
the projectStrict in the transforms
URL: https://github.com/apache/incubator-iceberg/pull/628#discussion_r355575396
 
 

 ##########
 File path: api/src/main/java/org/apache/iceberg/transforms/Bucket.java
 ##########
 @@ -111,45 +111,32 @@ public String toString() {
 
   @Override
   public UnboundPredicate<Integer> project(String name, BoundPredicate<T> 
predicate) {
-    if (predicate instanceof BoundUnaryPredicate) {
+    if (predicate.isUnaryPredicate()) {
       return Expressions.predicate(predicate.op(), name);
-    } else if (predicate instanceof BoundLiteralPredicate) {
-      BoundLiteralPredicate<T> pred = predicate.asLiteralPredicate();
-      switch (pred.op()) {
-        case EQ:
-          return Expressions.predicate(
-              pred.op(), name, apply(pred.literal().value()));
-//      case IN:
-//        return Expressions.predicate();
-        case STARTS_WITH:
-        default:
-          // comparison predicates can't be projected, notEq can't be projected
-          // TODO: small ranges can be projected.
-          // for example, (x > 0) and (x < 3) can be turned into in({1, 2}) 
and projected.
-          return null;
-      }
+    } else if (predicate.isLiteralPredicate() && predicate.op() == 
Expression.Operation.EQ) {
+      return Expressions.predicate(
+          predicate.op(), name, 
apply(predicate.asLiteralPredicate().literal().value()));
+    } else if (predicate.isSetPredicate() && predicate.op() == 
Expression.Operation.IN) { // notIn can't be projected
+      return ProjectionUtil.transformSet(name, (BoundSetPredicate<T>) 
predicate, this);
 
 Review comment:
   Nit: this should use `asSetPredicate()` instead of casting.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to