Fokko commented on code in PR #539: URL: https://github.com/apache/iceberg-python/pull/539#discussion_r1876738534
########## pyiceberg/transforms.py: ########## @@ -766,6 +858,47 @@ def _truncate_number( return None +def _truncate_number_strict( + name: str, pred: BoundLiteralPredicate[L], transform: Callable[[Optional[L]], Optional[L]] +) -> Optional[UnboundPredicate[Any]]: + boundary = pred.literal + + if not isinstance(boundary, (LongLiteral, DecimalLiteral, DateLiteral, TimestampLiteral)): + raise ValueError(f"Expected a numeric literal, got: {type(boundary)}") + + if isinstance(pred, BoundLessThan): + return LessThan(Reference(name), _transform_literal(transform, boundary)) + elif isinstance(pred, BoundLessThanOrEqual): + return LessThan(Reference(name), _transform_literal(transform, boundary.increment())) # type: ignore + elif isinstance(pred, BoundGreaterThan): + return GreaterThan(Reference(name), _transform_literal(transform, boundary)) + elif isinstance(pred, BoundGreaterThanOrEqual): + return GreaterThan(Reference(name), _transform_literal(transform, boundary.decrement())) # type: ignore Review Comment: Hmm, you might be onto something here: https://github.com/apache/iceberg-python/blob/88c4bad1d95175c3672bf7c47cba22ca803efcca/tests/test_transforms.py#L1006-L1009 https://github.com/apache/iceberg/blob/d402f83fc7b224b21242c506cf503e5bcbc8c867/api/src/test/java/org/apache/iceberg/transforms/TestDatesProjection.java#L139-L140 Luckily this code is not yet used, I'll write a patch tomorrow 👍 -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org