mbutrovich commented on code in PR #4982:
URL: https://github.com/apache/datafusion-comet/pull/4982#discussion_r3618042411


##########
spark/src/test/scala/org/apache/comet/CometFuzzIcebergSuite.scala:
##########
@@ -118,109 +120,56 @@ class CometFuzzIcebergSuite extends CometFuzzIcebergBase 
{
     }
   }
 
-  test("decode") {
+  test("filter pushdown - fuzz predicates over primitive columns") {
     val df = spark.table(icebergTableName)
-    // We want to make sure that the schema generator wasn't modified to 
accidentally omit
-    // BinaryType, since then this test would not run any queries and silently 
pass.
-    var testedBinary = false
-    for (field <- df.schema.fields if field.dataType == BinaryType) {
-      testedBinary = true
-      // Intentionally use odd capitalization of 'utf-8' to test normalization.
-      val sql = s"SELECT decode(${field.name}, 'utF-8') FROM $icebergTableName"
-      checkSparkAnswerAndOperator(sql)
-    }
-    assert(testedBinary)
-  }
-
-  test("regexp_replace") {
-    withSQLConf(CometConf.getExprAllowIncompatConfigKey("RegExpReplace") -> 
"true") {
-      val df = spark.table(icebergTableName)
-      // We want to make sure that the schema generator wasn't modified to 
accidentally omit
-      // StringType, since then this test would not run any queries and 
silently pass.
-      var testedString = false
-      for (field <- df.schema.fields if field.dataType == StringType) {
-        testedString = true
-        val sql = s"SELECT regexp_replace(${field.name}, 'a', 'b') FROM 
$icebergTableName"
-        checkSparkAnswerAndOperator(sql)
+    val primitiveColumns =
+      df.schema.fields.filterNot(f => isComplexType(f.dataType)).map(_.name)
+    assert(primitiveColumns.nonEmpty, "expected at least one primitive column 
in the fuzz schema")
+
+    for (name <- primitiveColumns) {
+      // Sample real values of the column's own type so predicates are always 
well-typed, avoiding
+      // per-type literal generation and SQL formatting. Skip NaN, whose 
comparison differs.
+      val values = df
+        .select(col(name))
+        .where(col(name).isNotNull)
+        .distinct()
+        .limit(3)
+        .collect()
+        .map(_.get(0))
+        .filterNot {
+          case d: Double => d.isNaN
+          case f: Float => f.isNaN
+          case _ => false
+        }
+        .toSeq
+
+      val c = col(name)
+      val predicates = scala.collection.mutable.ArrayBuffer[Column](c.isNull, 
c.isNotNull)
+      values.headOption.foreach { v =>
+        val l = lit(v)
+        // Comparisons, not-equal and explicit NOT (exercises the native 
rewrite_not path), and
+        // AND/OR combinations.
+        predicates ++= Seq(
+          c === l,
+          c =!= l,
+          c > l,
+          c >= l,
+          c < l,
+          c <= l,
+          !(c === l),
+          c.isNotNull && (c === l),
+          (c === l) || c.isNull)
       }
-      assert(testedString)
-    }
-  }
-
-  test("Iceberg temporal types written as INT96") {

Review Comment:
   Iceberg's writer doesn't write INT96. The only time they can end up in a 
Parquet data file is migration, which `"migration - INT96 timestamp"` covers in 
CometIcebergNativeSuite. These `ParquetOutputTimestampType` tests in 
CometFuzzIcebergSuite are a waste.



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