xh123637 opened a new pull request, #19033:
URL: https://github.com/apache/iceberg/pull/19033

   Fixes #19023
   
   `truncate(W)` wrapped near `MIN_VALUE`: `truncate(10, Integer.MIN_VALUE)` 
returned `2147483646` instead of the unrepresentable `-2147483650`, and 
partition pruning trusted the wrapped value, silently dropping rows. This 
computes the truncated value in widened arithmetic and throws 
`IllegalArgumentException` when the true result does not fit the partition 
type, and makes inclusive/strict projection return no projection (no pruning) 
when a predicate boundary truncates out of range, its `±1` adjustment 
overflows, or an `IN`/`NOT_IN` set contains such a value. The same fix covers 
`byte`/`short`, which wrapped identically.
   
   Proposed, not settled, semantics: fail affected writes loudly instead of 
writing a wrong partition value. Saturation was considered and not chosen here, 
because a saturated bucket can still mis-prune under strict projection. This 
does not repair files already written with wrapped partition values by 1.12.0, 
and the same question applies cross-engine (pyiceberg, Trino). Happy to switch 
direction if maintainers prefer saturation with an unbounded-below bucket.
   
   Test plan:
   - New tests: `TestTruncateUtil` (int/long/byte/short near `MIN_VALUE`) and 
`TestTruncatesProjection` (inclusive/strict projection near `MIN_VALUE`, 
including `i > MIN_VALUE` and `i BETWEEN MIN_VALUE AND -2147483640`).
   - A standalone JDK harness compiling the fixed `TruncateUtil` reproduced the 
issue's wrapped values on the old arithmetic (`2147483646`, 
`9223372036854775806`) and verified the new behavior: out-of-range values throw 
`IllegalArgumentException`, in-range values unchanged (16/16 checks pass).
   - The Gradle suites (`:iceberg-api:test TestTruncatesProjection`, 
`:iceberg-core:test TestTruncateUtil`) could not run in this sandbox: the 
Gradle wrapper cannot download its distribution, and the cached Gradle 9.7.1 
fails with "Could not dispatch a message to the daemon", so CI is the arbiter 
for the full suites. `spotlessApply`/`checkstyle` were not run for the same 
reason.
   
   ---
   **AI Disclosure**
   - Model: Muse Spark 1.3
   - Platform/Tool: Muse
   - Human Oversight: [unknown - human to fill in]
   - Prompt Summary: Fix apache/iceberg issue #19023 (truncate() wrapping near 
Integer/Long.MIN_VALUE) with tests and open a PR.
   


-- 
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]

Reply via email to