RussellSpitzer commented on code in PR #15070:
URL: https://github.com/apache/iceberg/pull/15070#discussion_r2905886720


##########
spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestAggregatePushDown.java:
##########
@@ -766,6 +766,53 @@ public void testNaN() {
     assertEquals("expected and actual should equal", expected, actual);
   }
 
+  @TestTemplate
+  public void testNanWithLowerAndUpperBoundMetrics() {
+    sql("CREATE TABLE %s (id int, data float) USING iceberg PARTITIONED BY 
(id)", tableName);
+    sql(
+        "INSERT INTO %s VALUES (1, float('nan')),"
+            + "(1, float('nan')), "
+            + "(1, 10.0), "
+            + "(2, 2), "
+            + "(2, float('nan')), "
+            + "(3, float('nan')), "
+            + "(3, 1)",
+        tableName);
+
+    // Validate all files has upper bound, lower bound and nan count
+    String countsQuery =
+        "select readable_metrics.data.nan_value_count > 0, "
+            + "isnull(readable_metrics.data.lower_bound), "
+            + "isnull(readable_metrics.data.upper_bound) "
+            + "from  %s.files";
+
+    Object[] expectedResult = new Object[] {true, false, false};
+    assertThat(sql(countsQuery, tableName))
+        .as("Data files should contain nan count, lower bound and upper 
bound.")
+        .allMatch(row -> Arrays.equals(row, expectedResult));
+
+    // Check aggregates are not pushdown
+    String select = "SELECT count(*), max(data), min(data), count(data) FROM 
%s";
+
+    List<Object[]> explain = sql("EXPLAIN " + select, tableName);
+    String explainString = 
explain.get(0)[0].toString().toLowerCase(Locale.ROOT);
+    boolean explainContainsPushDownAggregates = false;

Review Comment:
   Ok, we can save this for a followup but this looks pretty brittle - if the 
other tests are doing it it's fine for now.
   
   My worry is that the "non pushdown" has
    max(data#299)
    
    and the Pushdown has
    Max(data)#234
    
    And there isn't a lot of light between those two.



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