AP24110011695 opened a new pull request, #4285:
URL: https://github.com/apache/iceberg-python/pull/4285

   Fixes #4284
   
   ### Problem
   
   `Decimal.as_tuple().exponent` carries the **negated** scale, so 
`Decimal("1E+2")` (100) has exponent `+2`, i.e. scale `-2`. Three remaining 
call sites still read the scale as `abs(int(exponent))`, which turns that `-2` 
into `+2`:
   
   - `DecimalLiteral.increment()`: `1E+2` stepped to `0.02` instead of `2E+2`
   - `DecimalLiteral.decrement()`: `1E+2` stepped to `0.00` instead of `0E+2`
   - `truncate_decimal()`: `1.5E+3` truncated to `0.12` instead of `1.2E+3`
   
   Same root cause as #3997 (which fixed the `to(DecimalType)` / serialize 
sites); this PR fixes the remaining ones. For all positive-scale Decimals the 
two formulas are identical, so behavior only changes for negative-scale values, 
where it was wrong.
   
   ### Tests
   
   Failing-first regression tests, all verified locally (Python 3.12, Windows):
   
   - `test_decimal_literal_increment_negative_scale` / 
`test_decimal_literal_decrement_negative_scale` (extended 
`tests/expressions/test_literals.py`, mirroring the existing 
increment/decrement tests)
   - `test_truncate_decimal` (first coverage for this helper's normal path, 
including the floor-toward-negative-infinity case) + 
`test_truncate_decimal_negative_scale` in `tests/utils/test_decimal.py`
   
   All 4 tests fail on `main` and pass with this change. Full 
`tests/expressions/test_literals.py` (182 passed), 
`tests/utils/test_decimal.py`, and `tests/test_transforms.py` (275 passed; the 
17 pyarrow-parametrized failures in that file fail identically on unmodified 
`main` in this environment). `ruff` (pinned 0.14.3) format + check clean on all 
touched files; `mypy` (1.18.2, repo config) clean on the changed module.
   
   ---
   
   _Transparent disclosure: developed and verified with AI assistance under 
human direction, per the repo's agent guidelines._
   


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