jun-he commented on a change in pull request #2910:
URL: https://github.com/apache/iceberg/pull/2910#discussion_r685318203
##########
File path: python/iceberg/api/transforms/projection_util.py
##########
@@ -18,49 +18,138 @@
import decimal
-from iceberg.api.expressions import Expressions, Operation
-
-
-class ProjectionUtil(object):
- @staticmethod
- def truncate_integer(name, pred, transform):
- boundary = pred.lit.value
- if pred.op == Operation.LT:
- return Expressions.predicate(Operation.LT_EQ, name,
transform.apply(boundary - 1))
- elif pred.op == Operation.LT_EQ:
- return Expressions.predicate(Operation.LT_EQ, name,
transform.apply(boundary))
- elif pred.op == Operation.GT:
- return Expressions.predicate(Operation.GT_EQ, name,
transform.apply(boundary + 1))
- elif pred.op == Operation.GT_EQ:
- return Expressions.predicate(Operation.GT_EQ, name,
transform.apply(boundary))
- elif pred.op == Operation.EQ:
- return Expressions.predicate(pred.op, name,
transform.apply(boundary))
-
- def truncate_long(name, pred, transform):
- return ProjectionUtil.truncate_integer(name, pred, transform)
-
- def truncate_decimal(name, pred, transform):
- boundary = pred.lit.value
-
- if pred.op == Operation.LT:
- minus_one = boundary - decimal.Decimal(1)
- return Expressions.predicate(Operation.LT_EQ, name,
transform.apply(minus_one))
- elif pred.op == Operation.LT_EQ:
- return Expressions.predicate(Operation.LT_EQ, name,
transform.apply(boundary))
- elif pred.op == Operation.GT:
- plus_one = boundary + decimal.Decimal(1)
- return Expressions.predicate(Operation.GT_EQ, name,
transform.apply(plus_one))
- elif pred.op == Operation.GT_EQ:
- return Expressions.predicate(Operation.GT_EQ, name,
transform.apply(boundary))
- elif pred.op == Operation.EQ:
- return Expressions.predicate(pred.op, name,
transform.apply(boundary))
-
- def truncate_array(name, pred, transform):
- boundary = pred.lit.value
-
- if pred.op == Operation.LT or pred.op == Operation.LT_EQ:
- return Expressions.predicate(Operation.LT_EQ, name,
transform.apply(boundary))
- elif pred.op == Operation.GT or pred.op == Operation.GT_EQ:
- return Expressions.predicate(Operation.GT_EQ, name,
transform.apply(boundary))
- elif pred.op == Operation.EQ:
- return Expressions.predicate(pred.op, name,
transform.apply(boundary))
+from ..expressions import Expressions, Operation
+from ..expressions.predicate import UnboundPredicate
+
+
+def truncate_integer(name, pred, transform):
+ boundary = pred.lit.value
+ if pred.op == Operation.LT:
+ return Expressions.predicate(Operation.LT_EQ, name,
transform.apply(boundary - 1))
+ elif pred.op == Operation.LT_EQ:
+ return Expressions.predicate(Operation.LT_EQ, name,
transform.apply(boundary))
+ elif pred.op == Operation.GT:
+ return Expressions.predicate(Operation.GT_EQ, name,
transform.apply(boundary + 1))
+ elif pred.op == Operation.GT_EQ:
+ return Expressions.predicate(Operation.GT_EQ, name,
transform.apply(boundary))
+ elif pred.op == Operation.EQ:
+ return Expressions.predicate(pred.op, name, transform.apply(boundary))
+
+
+def truncate_integer_strict(name, pred, transform):
Review comment:
It has not been used in this patch. It will be needed for
projectStrict() in Dates and Truncate, which I plan to do next. The goal is to
update the whole expressions package. Yep, I will add some unite tests.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]