karmendra8386 opened a new pull request, #14806:
URL: https://github.com/apache/gravitino/pull/14806
### What changes were proposed in this pull request?
Fix `Literals.decimal_literal` in the Python client so decimal values with a
positive exponent are typed correctly. The precision now counts the zeroes a
positive exponent adds, and the scale is clamped to 0, so for example
`Decimal("1E+3")` becomes decimal(4,0) instead of raising `ValueError` from
`DecimalType.of` for the negative scale. Values without a positive exponent are
unchanged.
This PR takes over the draft #14214. On Nov 6, @jerryshao reviewed that
draft on #14213, confirmed the bug against current `main` and that the fix
looks correct, and said that if there was no update in the next few days I
would be welcome to take it over. There has been no update since Oct 25, so
this PR cherry-picks @Kayvan-Zahiri's commit as-is, with his authorship
preserved, and carries it through review. The one thing the earlier review did
not cover was running the Python tests locally, which is done here (see below).
### Why are the changes needed?
`decimal_literal` computed `scale = -exponent`, so any `Decimal` with a
positive exponent produced a negative scale and was rejected, even though the
value itself is a valid decimal.
Fixes #14213.
### Does this PR introduce _any_ user-facing change?
Decimal literals with positive exponents, which previously raised an error,
now produce a decimal type. No other behavior changes.
### How was this patch tested?
The cherry-picked commit adds regression tests to `test_literals.py`
covering positive exponents, the unchanged cases and the 38-digit precision
limit.
Ran locally on this branch: the literals tests pass (16 passed), and the
full client-python unit suite passes:
```
1434 passed, 1087 subtests passed
```
Pylint on the changed files is 10.00/10 and black check is clean.
--
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]