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

    https://github.com/apache/spark/pull/13188#discussion_r63992275
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/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.benchmark.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/" +
    --- End diff --
    
    one thing - these files should go into test/resources, and then we can get 
their path using the getresource function on the current thread's classloader.


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