jerryshao commented on issue #14213:
URL: https://github.com/apache/gravitino/issues/14213#issuecomment-6679584123
I checked this against current `main` and the bug is real:
`Literals.decimal_literal` computes `scale = -exponent`, so a positive exponent
such as `Decimal("1E+3")` gives scale -3 and `DecimalType.of` rejects it.
I also read the fix in #14214. Counting the positive-exponent zeroes in the
precision and clamping the scale to 0 looks correct to me. I compared the old
and new formulas on a set of values: positive exponents now give the expected
types (`1E+3` -> decimal(4,0), `-1.23E+4` -> decimal(5,0), `1E+37` ->
decimal(38,0)), while `1E-3`, `123.40`, `0.00`, `5` and `1.5E+1` are unchanged.
The tests also cover the 38-digit limit. I did not run the Python tests locally.
Two small notes, neither blocking:
- `Decimal("0E+3")` becomes decimal(4,0) rather than decimal(1,0). The value
is correct and the test expects it, it is just wider than necessary.
- `Literals.decimalLiteral` in the Java API uses `precision()` and `scale()`
from its own `Decimal` type, and I did not check whether it has a similar edge
case.
@Kayvan-Zahiri, #14214 has been a draft since Oct 25. Are you still planning
to finish it? If there is no update in the next few days, @karmendra8386 (who
offered above) is welcome to take it over. The change needs very little beyond
marking it ready for review.
--
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]