ggangadharan commented on code in PR #6878:
URL: https://github.com/apache/hive/pull/6878#discussion_r4294472832
##########
storage-api/src/test/org/apache/hadoop/hive/common/type/TestHiveDecimal.java:
##########
@@ -2953,6 +2953,17 @@ public void testRoundHalfEvenSpecial() {
}
}
+ @Test
+ public void testRoundDownAllIntegerDigitsInPlace() {
Review Comment:
This PR needs it. Decimal trunc now truncates in place through
HiveDecimalWritable.mutateSetScale(scale, ROUND_DOWN), and it's the first
caller of ROUND_DOWN with a negative scale.
When the truncation removes every integer digit, e.g. trunc(12345.678, -5),
fastRoundIntegerDown zeroes the digits but leaves fastSignum set. In place, the
writable then holds a malformed zero. It prints as 0, but signum() returns 1,
it is not equals to zero, and fastCompareTo sees it as greater than 0. So WHERE
trunc(d, -5) = 0 would silently drop rows.
The sibling functions fastRoundIntegerUp, HalfUp and HalfEven already set
fastSignum = 0 in the same branch; this adds the one missing line.
HiveDecimal.setScale() never hit the bug only because it writes into a fresh
object whose sign is already 0.
TestGenericUDFTrunc#testDecimalIntegerPartLargerThanLong caught it during
development (expected: HiveDecimal<0> but was: HiveDecimal<0>). The
TestHiveDecimal test pins the fix at the storage-api level.
--
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]