thomasrebele commented on code in PR #6194:
URL: https://github.com/apache/hive/pull/6194#discussion_r2538331684
##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/columnstats/merge/DecimalColumnStatsMergerTest.java:
##########
@@ -38,22 +41,28 @@
@Category(MetastoreUnitTest.class)
public class DecimalColumnStatsMergerTest {
- private static final Decimal DECIMAL_1 = DecimalUtils.getDecimal(1, 0);
- private static final Decimal DECIMAL_3 = DecimalUtils.getDecimal(3, 0);
- private static final Decimal DECIMAL_5 = DecimalUtils.getDecimal(5, 0);
- private static final Decimal DECIMAL_20 = DecimalUtils.getDecimal(2, 1);
+ /**
+ * Creates a decimal and checks its string representation.
+ */
+ private static Decimal getDecimal(String expected, int number, int scale) {
+ Decimal d = DecimalUtils.getDecimal(number, scale);
+ assertEquals(expected, MetaStoreServerUtils.decimalToString(d));
Review Comment:
We need the check to prevent human error when adding test cases.
The original test tried to create a decimal representing `20` with
`DECIMAL_20 = DecimalUtils.getDecimal(2, 1);` ([see line
44](https://github.com/apache/hive/pull/6194/files#diff-106c890ea911e2e5a4471a7fbfa4364d90a842b701655a046ea52e8f5e156719L44)),
however, the created decimal actually represents the number `0.2`, and the
comparison with `3` resulted in the opposite answer. The bug HIVE-29275 could
have been prevented, if there was a check what the decimals represent right
from the beginning.
--
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]