wangyum edited a comment on issue #25158: [SPARK-28395][SQL] Division operator 
support integral division
URL: https://github.com/apache/spark/pull/25158#issuecomment-511642418
 
 
   Benchmark and benchmark result:
   ```scala
   cat <<EOF > 
sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/SPARK_28395_Benchmark.scala
   /*
    * 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.execution.benchmark
   
   import org.apache.spark.benchmark.Benchmark
   import org.apache.spark.sql.internal.SQLConf
   
   /**
    * To run this benchmark:
    *   build/sbt "sql/test:runMain 
org.apache.spark.sql.execution.benchmark.SPARK_28395_Benchmark"
    */
   object SPARK_28395_Benchmark extends SqlBasedBenchmark {
   
     override def runBenchmarkSuite(mainArgs: Array[String]): Unit = {
   
       val title = "Benchmark SPARK-28395"
       runBenchmark(title) {
         withTempPath { dir =>
           val N = 6000000
           val df = spark.range(N)
   
           df.selectExpr("id as id1", "cast(id % 999999 as bigint) as id2")
             .write.mode("overwrite").parquet(dir.getCanonicalPath)
   
           val benchmark = new Benchmark(title, N, minNumIters = 5, output = 
output)
           Seq(false, true).foreach { integralDivision =>
             val name = if (integralDivision) "Integral division" else 
"Fractional division"
             benchmark.addCase(name) { _ =>
               withSQLConf(SQLConf.PREFER_INTEGRAL_DIVISION.key -> 
integralDivision.toString) {
                 spark.read.parquet(dir.getCanonicalPath).selectExpr("id1 / 
id2").collect()
               }
             }
           }
           benchmark.run()
         }
       }
     }
   }
   
   EOF
   ```
   
   ```
   [info] Java HotSpot(TM) 64-Bit Server VM 1.8.0_211-b12 on Linux 
3.10.0-957.1.3.el7.x86_64
   [info] Intel Core Processor (Broadwell)
   [info] Benchmark SPARK-28395:                    Best Time(ms)   Avg 
Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
   [info] 
------------------------------------------------------------------------------------------------------------------------
   [info] Fractional division                                3103           
5975         877          1.9         517.2       1.0X
   [info] Integral division                                  2084           
2293         195          2.9         347.3       1.5X
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to