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


##########
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()));

Review Comment:
   > Hm, but why do we need that extra complexity?
   
   I touched this class a few years ago, but I can’t recall the context 
anymore, sorry. Back then, 0-day bugs were fixed based on whatever made the 
most sense at the time, so in general, whatever makes sense to you, do 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