coderfender commented on code in PR #2979:
URL: https://github.com/apache/datafusion-comet/pull/2979#discussion_r2644433594


##########
spark/src/test/scala/org/apache/spark/sql/benchmark/CometCastStringToNumericBenchmark.scala:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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
+
+import org.apache.spark.sql.catalyst.expressions.Cast
+import org.apache.spark.sql.internal.SQLConf
+
+import org.apache.comet.CometConf
+
+case class CastStringToNumericConfig(
+    name: String,
+    query: String,
+    extraCometConfigs: Map[String, String] = Map.empty)
+
+// spotless:off
+/**
+ * Benchmark to measure performance of Comet cast from String to numeric 
types. To run this
+ * benchmark:
+ * `SPARK_GENERATE_BENCHMARK_FILES=1 make 
benchmark-org.apache.spark.sql.benchmark.CometCastStringToNumericBenchmark`
+ * Results will be written to 
"spark/benchmarks/CometCastStringToNumericBenchmark-**results.txt".
+ */
+// spotless:on
+object CometCastStringToNumericBenchmark extends CometBenchmarkBase {
+
+  private val castFunctions = Seq("CAST", "TRY_CAST")
+  private val targetTypes =
+    Seq("BOOLEAN", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", 
"DECIMAL(10,2)")

Review Comment:
   nit : Perhaps one could argue that `Boolean` isn't necessarily a `numeric` 
input ? Also , could we add some more higher precision + scale  decimals too ?
   
   https://spark.apache.org/docs/latest/sql-ref-datatypes.html



##########
spark/src/test/scala/org/apache/spark/sql/benchmark/CometCastStringToNumericBenchmark.scala:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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
+
+import org.apache.spark.sql.catalyst.expressions.Cast
+import org.apache.spark.sql.internal.SQLConf
+
+import org.apache.comet.CometConf
+
+case class CastStringToNumericConfig(
+    name: String,
+    query: String,
+    extraCometConfigs: Map[String, String] = Map.empty)
+
+// spotless:off
+/**
+ * Benchmark to measure performance of Comet cast from String to numeric 
types. To run this
+ * benchmark:
+ * `SPARK_GENERATE_BENCHMARK_FILES=1 make 
benchmark-org.apache.spark.sql.benchmark.CometCastStringToNumericBenchmark`
+ * Results will be written to 
"spark/benchmarks/CometCastStringToNumericBenchmark-**results.txt".
+ */
+// spotless:on
+object CometCastStringToNumericBenchmark extends CometBenchmarkBase {
+
+  private val castFunctions = Seq("CAST", "TRY_CAST")
+  private val targetTypes =
+    Seq("BOOLEAN", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", 
"DECIMAL(10,2)")
+
+  private val castConfigs = for {
+    castFunc <- castFunctions
+    targetType <- targetTypes
+  } yield CastStringToNumericConfig(
+    s"$castFunc String to $targetType",
+    s"SELECT $castFunc(c1 AS $targetType) FROM parquetV1Table",
+    Map(
+      SQLConf.ANSI_ENABLED.key -> "false",
+      CometConf.getExprAllowIncompatConfigKey(classOf[Cast]) -> "true"))

Review Comment:
   I was wondering if we could handle the cast compatibility on a case by case 
basis which would help us better evaluate custom implementations vs datafusion 
supported operation along with unsupported cast ops . This can be done in a 
follow up PR (I will file an issue once this is merged)



##########
spark/src/test/scala/org/apache/spark/sql/benchmark/CometCastStringToNumericBenchmark.scala:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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
+
+import org.apache.spark.sql.catalyst.expressions.Cast
+import org.apache.spark.sql.internal.SQLConf
+
+import org.apache.comet.CometConf
+
+case class CastStringToNumericConfig(
+    name: String,
+    query: String,
+    extraCometConfigs: Map[String, String] = Map.empty)
+
+// spotless:off
+/**
+ * Benchmark to measure performance of Comet cast from String to numeric 
types. To run this
+ * benchmark:
+ * `SPARK_GENERATE_BENCHMARK_FILES=1 make 
benchmark-org.apache.spark.sql.benchmark.CometCastStringToNumericBenchmark`
+ * Results will be written to 
"spark/benchmarks/CometCastStringToNumericBenchmark-**results.txt".
+ */
+// spotless:on

Review Comment:
   @andygrove nit :   perhaps we might dont need to turn off spotless given 
that all other benchmarks dont ? 
   Example comment form `CometCastBenchmark`
   
   ```
   /**
    * Benchmark to measure Comet execution performance. To run this benchmark:
    * {{{
    *   SPARK_GENERATE_BENCHMARK_FILES=1 make 
benchmark-org.apache.spark.sql.benchmark.CometCastBenchmark
    * }}}
    *
    * Results will be written to 
"spark/benchmarks/CometCastBenchmark-**results.txt".
    */
   
   ```



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