Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark3 tpcds setup #187

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ val databaseName = ... // name of database to create.
val scaleFactor = ... // scaleFactor defines the size of the dataset to generate (in GB).
val format = ... // valid spark format like parquet "parquet".
// Run:
val tables = new TPCDSTables(sqlContext,
val tables = new TPCDSTables(spark, sqlContext,
dsdgenDir = "/tmp/tpcds-kit/tools", // location of dsdgen
scaleFactor = scaleFactor,
useDoubleForDecimal = false, // true to replace DecimalType with DoubleType
Expand Down Expand Up @@ -188,4 +188,4 @@ For running parallel TPCDS streams:

### tpch_run notebook

This notebook can be used to run TPCH queries. Data needs be generated first.
This notebook can be used to run TPCH queries. Data needs be generated first.
6 changes: 3 additions & 3 deletions src/main/notebooks/TPC-multi_datagen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ def getBenchmarkData(benchmark: String, scaleFactor: String) = benchmark match {

case "TPCH" => (
s"tpch_sf${scaleFactor}_${fileFormat}${dbSuffix}",
new TPCHTables(spark.sqlContext, dbgenDir = s"${baseDatagenFolder}/dbgen", scaleFactor = scaleFactor, useDoubleForDecimal = false, useStringForDate = false, generatorParams = Nil),
new TPCHTables(spark, spark.sqlContext, dbgenDir = s"${baseDatagenFolder}/dbgen", scaleFactor = scaleFactor, useDoubleForDecimal = false, useStringForDate = false, generatorParams = Nil),
s"$baseLocation/tpch/sf${scaleFactor}_${fileFormat}")

case "TPCDS" if !TPCDSUseLegacyOptions => (
s"tpcds_sf${scaleFactor}_${fileFormat}${dbSuffix}",
new TPCDSTables(spark.sqlContext, dsdgenDir = s"${baseDatagenFolder}/dsdgen", scaleFactor = scaleFactor, useDoubleForDecimal = false, useStringForDate = false),
new TPCDSTables(spark, spark.sqlContext, dsdgenDir = s"${baseDatagenFolder}/dsdgen", scaleFactor = scaleFactor, useDoubleForDecimal = false, useStringForDate = false),
s"$baseLocation/tpcds-2.4/sf${scaleFactor}_${fileFormat}")

case "TPCDS" if TPCDSUseLegacyOptions => (
s"tpcds_sf${scaleFactor}_nodecimal_nodate_withnulls${dbSuffix}",
new TPCDSTables(spark.sqlContext, s"${baseDatagenFolder}/dsdgen", scaleFactor = scaleFactor, useDoubleForDecimal = true, useStringForDate = true),
new TPCDSTables(spark, spark.sqlContext, s"${baseDatagenFolder}/dsdgen", scaleFactor = scaleFactor, useDoubleForDecimal = true, useStringForDate = true),
s"$baseLocation/tpcds/sf$scaleFactor-$fileFormat/useDecimal=false,useDate=false,filterNull=false")
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/com/databricks/spark/sql/perf/Tables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.apache.spark.SparkContext
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types._
import org.apache.spark.sql.{Row, SQLContext, SaveMode}
import org.apache.spark.sql.{Row, SQLContext, SaveMode, SparkSession}


/**
Expand Down Expand Up @@ -94,7 +94,7 @@ trait DataGenerator extends Serializable {
}


abstract class Tables(sqlContext: SQLContext, scaleFactor: String,
abstract class Tables(sqlSession SparkSession, sqlContext: SQLContext, scaleFactor: String,
useDoubleForDecimal: Boolean = false, useStringForDate: Boolean = false)
extends Serializable {

Expand Down Expand Up @@ -254,7 +254,7 @@ abstract class Tables(sqlContext: SQLContext, scaleFactor: String,
if (!tableExists || overwrite) {
println(s"Creating external table $name in database $databaseName using data stored in $location.")
log.info(s"Creating external table $name in database $databaseName using data stored in $location.")
sqlContext.createExternalTable(qualifiedTableName, location, format)
sqlSession.createTable(qualifiedTableName, location, format)
}
if (partitionColumns.nonEmpty && discoverPartitions) {
println(s"Discovering partitions for table $name.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.databricks.spark.sql.perf
import com.databricks.spark.sql.perf.{BlockingLineStream, DataGenerator, Table, Tables}

import org.apache.spark.SparkContext
import org.apache.spark.sql.SQLContext
import org.apache.spark.sql.{SQLContext, SparkSession}

class DSDGEN(dsdgenDir: String) extends DataGenerator {
val dsdgen = s"$dsdgenDir/dsdgen"
Expand Down Expand Up @@ -55,12 +55,13 @@ class DSDGEN(dsdgenDir: String) extends DataGenerator {


class TPCDSTables(
sqlSession: SparkSession
sqlContext: SQLContext,
dsdgenDir: String,
scaleFactor: String,
useDoubleForDecimal: Boolean = false,
useStringForDate: Boolean = false)
extends Tables(sqlContext, scaleFactor, useDoubleForDecimal, useStringForDate) {
extends Tables(sqlSession, sqlContext, scaleFactor, useDoubleForDecimal, useStringForDate) {
import sqlContext.implicits._

val dataGenerator = new DSDGEN(dsdgenDir)
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/com/databricks/spark/sql/perf/tpch/TPCH.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.databricks.spark.sql.perf.ExecutionMode.CollectResults
import org.apache.commons.io.IOUtils

import org.apache.spark.SparkContext
import org.apache.spark.sql.SQLContext
import org.apache.spark.sql.{SQLContext, SparkSession}

class DBGEN(dbgenDir: String, params: Seq[String]) extends DataGenerator {
val dbgen = s"$dbgenDir/dbgen"
Expand Down Expand Up @@ -64,13 +64,14 @@ class DBGEN(dbgenDir: String, params: Seq[String]) extends DataGenerator {
}

class TPCHTables(
sqlSession: SparkSession
sqlContext: SQLContext,
dbgenDir: String,
scaleFactor: String,
useDoubleForDecimal: Boolean = false,
useStringForDate: Boolean = false,
generatorParams: Seq[String] = Nil)
extends Tables(sqlContext, scaleFactor, useDoubleForDecimal, useStringForDate) {
extends Tables(sqlSession, sqlContext, scaleFactor, useDoubleForDecimal, useStringForDate) {
import sqlContext.implicits._

val dataGenerator = new DBGEN(dbgenDir, generatorParams)
Expand Down