thomasrebele commented on code in PR #6194:
URL: https://github.com/apache/hive/pull/6194#discussion_r2541817192


##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/columnstats/merge/DecimalColumnStatsMergerTest.java:
##########
@@ -180,47 +188,59 @@ public void testMergeNonNullValues() {
 
   @Test
   public void testDecimalCompareEqual() {
-    assertTrue(DECIMAL_3.equals(DECIMAL_3));
+    assertTrue(DECIMAL_3.equals(getDecimal("3", 3, 0)));
+    // the equals method does not check for numerical equality,
+    // e.g., DECIMAL_3 is not equal to getDecimal("3", 30, 1)
   }
 
   @Test
   public void testDecimalCompareDoesntEqual() {
     assertFalse(DECIMAL_3.equals(DECIMAL_5));
+    assertFalse(DECIMAL_3.equals(getDecimal("30", 3, -1)));
   }
 
-  @Test
-  public void testCompareSimple() {
-    DecimalColumnStatsDataInspector data1 = new 
DecimalColumnStatsDataInspector(DATA_3);
-    DecimalColumnStatsDataInspector data2 = new 
DecimalColumnStatsDataInspector(DATA_5);
-    assertEquals(DECIMAL_5, merger.mergeHighValue(merger.getHighValue(data1), 
merger.getHighValue(data2)));
+  private void checkMergedValue(Decimal low, Decimal high) {
+    Objects.requireNonNull(low);
+    Objects.requireNonNull(high);
+    assertTrue(MetaStoreServerUtils.decimalToDouble(low) < 
MetaStoreServerUtils.decimalToDouble(high));
+    var data1 = new DecimalColumnStatsDataInspector();
+    data1.setLowValue(low);
+    data1.setHighValue(low);
+    var data2 = new DecimalColumnStatsDataInspector();
+    data2.setLowValue(high);
+    data2.setHighValue(high);
+
+    assertEquals(low, merger.mergeLowValue(data1.getLowValue(), 
data2.getLowValue()));
+    assertEquals(low, merger.mergeLowValue(data2.getLowValue(), 
data1.getLowValue()));
+    assertEquals(high, merger.mergeHighValue(data1.getHighValue(), 
data2.getHighValue()));
+    assertEquals(high, merger.mergeHighValue(data2.getHighValue(), 
data1.getHighValue()));

Review Comment:
   I don't see a problem here. I could certainly check the `mergeHighValue` in 
separate test methods. I don't think that the added code to separate the checks 
will make the test class easier to understand. If you insist, I can surely work 
on it.



-- 
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]

Reply via email to