Ankitkj1999 commented on code in PR #18941:
URL: https://github.com/apache/iceberg/pull/18941#discussion_r4577586252
##########
api/src/main/java/org/apache/iceberg/transforms/ProjectionUtil.java:
##########
@@ -44,11 +44,17 @@ static <T> UnboundPredicate<T> truncateInteger(
int boundary = pred.literal().value();
switch (pred.op()) {
case LT:
+ if (boundary == Integer.MIN_VALUE) {
+ return null;
Review Comment:
Thanks for the thoughtful review and for catching this! You're completely
right — because `InclusiveProjection` skips `null` and retains
`Expressions.alwaysTrue()`, returning `null` preserves all partitions and loses
the pruning of lower partitions (like partition 0) that occurred under the
overflow.
Because `Transform.project` returns `UnboundPredicate<T>` rather than
`Expression`, `ProjectionUtil` cannot return `Expressions.alwaysFalse()`
directly when called on a `BoundPredicate`.
The proper place to eliminate these impossible conditions so partition
pruning takes effect seems to be during expression binding in
`UnboundPredicate.bindLiteralOperation` (analogous to how `Literals.aboveMax()`
and `Literals.belowMin()` already return `Expressions.alwaysFalse()` for `GT`
and `LT`). Binding `col < MIN_VALUE` and `col > MAX_VALUE` to
`Expressions.alwaysFalse()` allows scan planning to short-circuit manifests and
data files immediately.
Would you prefer updating this PR to handle the binding simplification in
`UnboundPredicate` (alongside guarding `ProjectionUtil` against overflow), or
would you prefer keeping this PR scoped strictly to arithmetic safety in
`ProjectionUtil` and opening a separate PR for the binding simplification?
--
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]