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/08/07 18:59:23 UTC

[GitHub] [incubator-iceberg] sujithjay commented on a change in pull request #327: Introduce startsWith Predicate

sujithjay commented on a change in pull request #327: Introduce startsWith Predicate
URL: https://github.com/apache/incubator-iceberg/pull/327#discussion_r311713190
 
 

 ##########
 File path: api/src/main/java/org/apache/iceberg/transforms/Truncate.java
 ##########
 @@ -213,20 +213,35 @@ public boolean canTransform(Type type) {
 
     @Override
     public UnboundPredicate<CharSequence> project(String name,
-                                                  BoundPredicate<CharSequence> pred) {
-      if (pred.op() == NOT_NULL || pred.op() == IS_NULL) {
-        return Expressions.predicate(pred.op(), name);
+                                                  BoundPredicate<CharSequence> predicate) {
+      switch (predicate.op()) {
+        case NOT_NULL:
+        case IS_NULL:
+          return Expressions.predicate(predicate.op(), name);
+        case STARTS_WITH:
+        default:
+          return ProjectionUtil.truncateArray(name, predicate, this);
       }
-      return ProjectionUtil.truncateArray(name, pred, this);
     }
 
     @Override
     public UnboundPredicate<CharSequence> projectStrict(String name,
-                                                        BoundPredicate<CharSequence> pred) {
-      if (pred.op() == NOT_NULL || pred.op() == IS_NULL) {
-        return Expressions.predicate(pred.op(), name);
+                                                        BoundPredicate<CharSequence> predicate) {
+      switch (predicate.op()) {
+        case IS_NULL:
+        case NOT_NULL:
+          return Expressions.predicate(predicate.op(), name);
+        case STARTS_WITH:
+          if (predicate.literal().value().length() < width()) {
+            return Expressions.predicate(predicate.op(), name, predicate.literal().value());
+          } else if (predicate.literal().value().length() == width()) {
+            return Expressions.equal(name, predicate.literal().value());
+          } else {
+            return null;
 
 Review comment:
   Does returning `null` here still make sense, in light of recent changes? Or should it be returning `ProjectionUtil.truncateArrayStrict(name, predicate, this)` ?

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