ggangadharan opened a new pull request, #3756:
URL: https://github.com/apache/hive/pull/3756
### What changes were proposed in this pull request?
The truncate UDF returns incorrect output for higher values
Ex:
select trunc(CAST('123456789.123456789' AS DECIMAL(18,9)), 8);
input = 123456711889.122345897
pow = 10,00000000
result = input * pow = 12345671188912234589.7 <-- overflowing
New Logic
input = 123456711889.122345897
IntegerPart = 123456711889
decimalPart = 122345897
decResult = decimalPart * pow = 12234589.7
newDecimal = decResult.longValue * pow / pow = 0.12234589
result = IntegerPart + newDecimal
### Why are the changes needed?
Fixing the UDF TRUNC
### Does this PR introduce _any_ user-facing change?
Yes, the output of the truncate udf changes.
### How was this patch tested?
With q files and manual tests.
--
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]