Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13188#discussion_r63971900
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/tpcds/TPCDSQueryBenchmark.scala
 ---
    @@ -0,0 +1,132 @@
    +/*
    + * 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.datasources.parquet.tpcds
    +
    +import java.io.File
    +
    +import org.apache.spark.SparkConf
    +import org.apache.spark.sql.SparkSession
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.analysis.UnresolvedRelation
    +import org.apache.spark.sql.catalyst.expressions.SubqueryExpression
    +import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
    +import org.apache.spark.sql.catalyst.util._
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Benchmark
    +
    +/**
    + * Benchmark to measure TPCDS query performance.
    + * To run this:
    + *  spark-submit --class <this class> --jars <spark sql test jar>
    + */
    +object TPCDSQueryBenchmark {
    +  val conf =
    +    new SparkConf()
    +      .setMaster("local[1]")
    +      .setAppName("test-sql-context")
    +      .set("spark.sql.parquet.compression.codec", "snappy")
    +      .set("spark.sql.shuffle.partitions", "4")
    +      .set("spark.driver.memory", "3g")
    +      .set("spark.executor.memory", "3g")
    +      .set("spark.sql.autoBroadcastJoinThreshold", (20 * 1024 * 
1024).toString)
    +
    +  val spark = SparkSession.builder.config(conf).getOrCreate()
    +
    +  val tables = Seq("catalog_page", "catalog_returns", "customer", 
"customer_address",
    +    "customer_demographics", "date_dim", "household_demographics", 
"inventory", "item",
    +    "promotion", "store", "store_returns", "catalog_sales", "web_sales", 
"store_sales",
    +    "web_returns", "web_site", "reason", "call_center", "warehouse", 
"ship_mode", "income_band",
    +    "time_dim", "web_page")
    +
    +  def setupTables(dataLocation: String): Map[String, Long] = {
    +    tables.map { tableName =>
    +      
spark.read.parquet(s"$dataLocation/$tableName").createOrReplaceTempView(tableName)
    +      tableName -> spark.table(tableName).count()
    +    }.toMap
    +  }
    +
    +  def tpcdsAll(dataLocation: String, queries: Seq[String]): Unit = {
    +    require(dataLocation.nonEmpty,
    +      "please modify the value of dataLocation to point to your local 
TPCDS data")
    +    val tableSizes = setupTables(dataLocation)
    +    spark.conf.set(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key, "true")
    +    spark.conf.set(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key, "true")
    +    queries.foreach { name =>
    +      val queriesString = fileToString(new 
File(s"sql/core/src/test/scala/org/apache/spark/sql/" +
    +        s"execution/datasources/parquet/tpcds/queries/$name.sql"))
    +
    +      // This is an indirect hack to estimate the size of each query's 
input by traversing the
    +      // logical plan and adding up the sizes of all tables that appear in 
the plan. Note that this
    +      // currently doesn't take WITH subqueries into account which might 
lead to fairly inaccurate
    +      // per-row processing time for those cases.
    +      val queryRelations = scala.collection.mutable.HashSet[String]()
    +      spark.sql(queriesString).queryExecution.logical.map {
    +        case ur @ UnresolvedRelation(t: TableIdentifier, _) =>
    +          queryRelations.add(t.table)
    +        case lp: LogicalPlan =>
    +          lp.expressions.foreach { _ foreach {
    +            case subquery: SubqueryExpression =>
    +              subquery.plan.foreach {
    +                case ur @ UnresolvedRelation(t: TableIdentifier, _) =>
    +                  queryRelations.add(t.table)
    +                case _ =>
    +              }
    +            case _ =>
    +          }
    +        }
    +        case _ =>
    +      }
    +      val numRows = queryRelations.map(tableSizes.getOrElse(_, 0L)).sum
    +      val benchmark = new Benchmark("TPCDS Snappy (scale = 5)", numRows, 1)
    --- End diff --
    
    The scale may be not 5


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to