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_r307872508
##########
File path: api/src/main/java/org/apache/iceberg/transforms/ProjectionUtil.java
##########
@@ -52,6 +52,90 @@ private ProjectionUtil() {}
}
}
+ static UnboundPredicate<Integer> truncateIntegerStrict(
+ String name, BoundPredicate<Integer> pred, Transform<Integer, Integer>
transform) {
+ int boundary = pred.literal().value();
+ switch (pred.op()) {
+ case LT:
+ // predicate would be <= the previous partition
+ 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))) {
+ // Literal is not at upper boundary, for eg: 2019-07-02T02:12:34.0000
+ // the predicate can be < 2019-07-02
+ return predicate(Expression.Operation.LT, name,
transform.apply(boundary));
+ } else {
+ // Literal is not at upper boundary, for eg:
2019-07-02T23:59:59.99999
+ // the predicate can be <= 2019-07-02
+ return predicate(Expression.Operation.LT_EQ, name,
transform.apply(boundary));
+ }
+ case GT:
+ // predicate would be >= the next partition
+ 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))) {
+ // Literal is not at lower boundary, for eg: 2019-07-02T02:12:34.0000
+ // the predicate can be > 2019-07-02
+ return predicate(Expression.Operation.GT, name,
transform.apply(boundary));
+ } else {
+ // Literal was at the lower boundary, for eg:
2019-07-02T00:00:00.0000
+ // the predicate can be >= 2019-07-02
+ return predicate(Expression.Operation.GT_EQ, name,
transform.apply(boundary));
+ }
+ case NOT_EQ:
+ return predicate(Expression.Operation.NOT_EQ, name,
transform.apply(boundary));
+ case EQ:
+ // there is no predicate that guarantees equality because adjacent
ints transform to the same value
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ static UnboundPredicate<Integer> truncateLongStrict(
+ String name, BoundPredicate<Long> pred, Transform<Long, Integer>
transform) {
+ long boundary = pred.literal().value();
+ switch (pred.op()) {
+ case LT:
+ // predicate would be <= the previous partition
+ 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 + 1L).equals(transform.apply(boundary))) {
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]