AP24110011695 opened a new pull request, #4287:
URL: https://github.com/apache/iceberg-python/pull/4287
Fixes #4286
### Problem
`float('inf')` is a valid float/double literal (only NaN is rejected at
construction), but converting it to a `DecimalType` leaked a bare
`decimal.InvalidOperation` from inside `Decimal.quantize()` — with no context
and inconsistent with every other impossible conversion in the module, which
raises `ValueError("Could not convert X into a Y…")`:
```python
DoubleLiteral(float("inf")).to(DecimalType(10, 2))
# decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
```
### Fix
Both `FloatLiteral.to(DecimalType)` and `DoubleLiteral.to(DecimalType)` now
raise `ValueError("Could not convert inf into a decimal(9, 2), value is not
finite")` before quantizing. The message follows the suffix style introduced
for this module in #4029.
### Tests
Two regression tests (fail on `main` with `decimal.InvalidOperation`, pass
with this change):
- `test_float_to_decimal_conversion_with_infinity`
- `test_double_to_decimal_conversion_with_infinity`
Full `tests/expressions/test_literals.py`: 177 passed.
`tests/test_transforms.py`: 275 passed with the same 17 pyarrow-parametrized
failures as unmodified `main` in this environment (baseline verified). `ruff`
(pinned 0.14.3) check + format clean on both touched files.
---
_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]