Fokko commented on code in PR #1388: URL: https://github.com/apache/iceberg-python/pull/1388#discussion_r1944716167
########## pyiceberg/expressions/visitors.py: ########## @@ -1731,3 +1732,230 @@ def _can_contain_nulls(self, field_id: int) -> bool: def _can_contain_nans(self, field_id: int) -> bool: return (nan_count := self.nan_counts.get(field_id)) is not None and nan_count > 0 + + +class ResidualVisitor(BoundBooleanExpressionVisitor[BooleanExpression], ABC): + """Finds the residuals for an Expression the partitions in the given PartitionSpec. + + A residual expression is made by partially evaluating an expression using partition values. + For example, if a table is partitioned by day(utc_timestamp) and is read with a filter expression + utc_timestamp >= a and utc_timestamp <= b, then there are 4 possible residuals expressions + for the partition data, d: + + + 1. If d > day(a) and d < day(b), the residual is always true + 2. If d == day(a) and d != day(b), the residual is utc_timestamp >= a + 3. if d == day(b) and d != day(a), the residual is utc_timestamp <= b + 4. If d == day(a) == day(b), the residual is utc_timestamp >= a and utc_timestamp <= b + + Partition data is passed using StructLike. Residuals are returned by residualFor(StructLike). + + This class is thread-safe. Review Comment: ```suggestion 1. If d > day(a) and d < day(b), the residual is always true 2. If d == day(a) and d != day(b), the residual is utc_timestamp > a 3. if d == day(b) and d != day(a), the residual is utc_timestamp < b 4. If d == day(a) == day(b), the residual is utc_timestamp > a and utc_timestamp < b Partition data is passed using StructLike. Residuals are returned by residualFor(StructLike). ``` -- 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