ZENOTME commented on code in PR #539: URL: https://github.com/apache/iceberg-python/pull/539#discussion_r1876215827
########## 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: Hi, I'm confused about decrement here. @Fokko E.g. col1 is date type and transform is month, for the predicate is `col1 >= 1970-01-02`, this will cause the predicate project to `month(col1) > -1`, e.g. the col1 is `1970-01-01`, `1970-01-01 >= 1970-01-02` is false but `month(1970-01-01) = 0 > -1` is true. -- 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