You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2019/12/09 17:15:36 UTC

[GitHub] [incubator-iceberg] rdblue commented on a change in pull request #628: Implement the project and the projectStrict in the transforms

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:
users@infra.apache.org


With regards,
Apache Git Services

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