moulimukherjee commented on a change in pull request #283: Add projectStrict 
for Dates and Timestamps
URL: https://github.com/apache/incubator-iceberg/pull/283#discussion_r306973429
 
 

 ##########
 File path: api/src/main/java/org/apache/iceberg/transforms/ProjectionUtil.java
 ##########
 @@ -52,6 +52,84 @@ private ProjectionUtil() {}
     }
   }
 
+  static <T> UnboundPredicate<T> truncateIntegerStrict(
+      String name, BoundPredicate<Integer> pred, Transform<Integer, T> 
transform) {
+    int boundary = pred.literal().value();
+    switch (pred.op()) {
+      case LT:
+        // Checking if the literal is at the lower partition boundary
+        if (transform.apply(boundary - 1).equals(transform.apply(boundary))) {
+          return predicate(Expression.Operation.LT, name, 
transform.apply(boundary - 1));
+        } else {
+          return predicate(Expression.Operation.LT_EQ, name, 
transform.apply(boundary - 1));
+        }
+      case LT_EQ:
+        // Checking if the literal is at the upper partition boundary
+        if (transform.apply(boundary + 1).equals(transform.apply(boundary))) {
+          return predicate(Expression.Operation.LT, name, 
transform.apply(boundary));
+        } else {
+          return predicate(Expression.Operation.LT_EQ, name, 
transform.apply(boundary));
+        }
+      case GT:
+        // Checking if the literal is at the upper partition boundary
+        if (transform.apply(boundary + 1).equals(transform.apply(boundary))) {
+          return predicate(Expression.Operation.GT, name, 
transform.apply(boundary + 1));
+        } else {
+          return predicate(Expression.Operation.GT_EQ, name, 
transform.apply(boundary + 1));
+        }
+      case GT_EQ:
+        // Checking if the literal is at the lower partition boundary
+        if (transform.apply(boundary - 1).equals(transform.apply(boundary))) {
+          return predicate(Expression.Operation.GT, name, 
transform.apply(boundary));
+        } else {
+          return predicate(Expression.Operation.GT_EQ, name, 
transform.apply(boundary));
+        }
+      case NOT_EQ:
+        return predicate(Expression.Operation.NOT_EQ, name, 
transform.apply(boundary));
+      default:
 
 Review comment:
   Ack

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