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


##########
spark/src/test/scala/org/apache/spark/sql/benchmark/CometComparisonExpressionBenchmark.scala:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.spark.sql.benchmark
+
+case class ComparisonExprConfig(
+    name: String,
+    query: String,
+    extraCometConfigs: Map[String, String] = Map.empty)
+
+/**
+ * Comprehensive benchmark for Comet comparison and predicate expressions. To 
run this benchmark:
+ * {{{
+ *   SPARK_GENERATE_BENCHMARK_FILES=1 make 
benchmark-org.apache.spark.sql.benchmark.CometComparisonExpressionBenchmark
+ * }}}
+ * Results will be written to 
"spark/benchmarks/CometComparisonExpressionBenchmark-**results.txt".
+ */
+object CometComparisonExpressionBenchmark extends CometBenchmarkBase {
+
+  private val comparisonExpressions = List(
+    ComparisonExprConfig("equal_to", "SELECT c_int = c_int2 FROM 
parquetV1Table"),
+    ComparisonExprConfig("not_equal_to", "SELECT c_int != c_int2 FROM 
parquetV1Table"),
+    ComparisonExprConfig("less_than", "SELECT c_int < c_int2 FROM 
parquetV1Table"),
+    ComparisonExprConfig("less_than_or_equal", "SELECT c_int <= c_int2 FROM 
parquetV1Table"),
+    ComparisonExprConfig("greater_than", "SELECT c_int > c_int2 FROM 
parquetV1Table"),
+    ComparisonExprConfig("greater_than_or_equal", "SELECT c_int >= c_int2 FROM 
parquetV1Table"),
+    ComparisonExprConfig("equal_null_safe", "SELECT c_int <=> c_int2 FROM 
parquetV1Table"),
+    ComparisonExprConfig("is_null", "SELECT c_int IS NULL FROM 
parquetV1Table"),
+    ComparisonExprConfig("is_not_null", "SELECT c_int IS NOT NULL FROM 
parquetV1Table"),
+    ComparisonExprConfig("is_nan_float", "SELECT isnan(c_float) FROM 
parquetV1Table"),
+    ComparisonExprConfig("is_nan_double", "SELECT isnan(c_double) FROM 
parquetV1Table"),
+    ComparisonExprConfig("and", "SELECT (c_int > 0) AND (c_int2 < 100) FROM 
parquetV1Table"),
+    ComparisonExprConfig("or", "SELECT (c_int > 0) OR (c_int2 < 100) FROM 
parquetV1Table"),
+    ComparisonExprConfig("not", "SELECT NOT (c_int > 0) FROM parquetV1Table"),
+    ComparisonExprConfig(
+      "in_list",
+      "SELECT c_int IN (1, 10, 100, 1000, 10000) FROM parquetV1Table"),
+    ComparisonExprConfig(
+      "not_in_list",
+      "SELECT c_int NOT IN (1, 10, 100, 1000, 10000) FROM parquetV1Table"))
+
+  override def runCometBenchmark(mainArgs: Array[String]): Unit = {
+    val values = 1024 * 1024
+
+    runBenchmarkWithTable("Comparison expression benchmarks", values) { v =>
+      withTempPath { dir =>
+        withTempTable("parquetV1Table") {
+          prepareTable(
+            dir,
+            spark.sql(s"""
+              SELECT
+                CASE WHEN value % 10 = 0 THEN NULL ELSE CAST((value % 100000) 
- 50000 AS INT) END AS c_int,

Review Comment:
   Would you add a succinct comment that gives a high level summary of the data 
distribution you're trying to create? We can certainly read through the `CASE 
WHEN` logic, but some are `% 10` and others `% 50` and it's not obvious what 
the underlying values and math is hard.



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