-
Notifications
You must be signed in to change notification settings - Fork 413
Add a convenient class to generate TPC-DS data #196
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
abf08eb
Gen TPCDS data.
wangyum d533a49
fix
wangyum 720a1b8
Update src/main/scala/com/databricks/spark/sql/perf/tpcds/GenTPCDSDat…
wangyum 66e2b12
Merge remote-tracking branch 'upstream/master' into GenTPCDSData
wangyum 0914c5e
Merge branch 'GenTPCDSData' of https://github.com/wangyum/spark-sql-p…
wangyum 947cc72
fix
wangyum b09d1ce
fix
wangyum 6518df4
fix
wangyum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/main/scala/com/databricks/spark/sql/perf/tpcds/GenTPCDSData.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| /* | ||
| * Copyright 2015 Databricks Inc. | ||
| * | ||
| * Licensed 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 com.databricks.spark.sql.perf.tpcds | ||
|
|
||
| import org.apache.spark.sql.SparkSession | ||
|
|
||
| case class GenTPCDSDataConfig( | ||
| master: String = "local[*]", | ||
| dsdgenDir: String = null, | ||
| scaleFactor: String = null, | ||
HyukjinKwon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| location: String = null, | ||
| format: String = null, | ||
| useDoubleForDecimal: Boolean = false, | ||
| useStringForDate: Boolean = false, | ||
| overwrite: Boolean = false, | ||
| partitionTables: Boolean = true, | ||
| clusterByPartitionColumns: Boolean = true, | ||
| filterOutNullPartitionValues: Boolean = true, | ||
| tableFilter: String = "", | ||
| numPartitions: Int = 100) | ||
|
|
||
| /** | ||
| * Gen TPCDS data. | ||
| * To run this: | ||
| * {{{ | ||
| * build/sbt "test:runMain <this class> -d <dsdgenDir> -s <scaleFactor> -l <location> -f <format>" | ||
| * }}} | ||
| */ | ||
| object GenTPCDSData { | ||
| def main(args: Array[String]): Unit = { | ||
| val parser = new scopt.OptionParser[GenTPCDSDataConfig]("Gen-TPC-DS-data") { | ||
| opt[String]('m', "master") | ||
| .action { (x, c) => c.copy(master = x) } | ||
| .text("the Spark master to use, default to local[*]") | ||
| opt[String]('d', "dsdgenDir") | ||
| .action { (x, c) => c.copy(dsdgenDir = x) } | ||
| .text("location of dsdgen") | ||
| .required() | ||
| opt[String]('s', "scaleFactor") | ||
| .action((x, c) => c.copy(scaleFactor = x)) | ||
| .text("scaleFactor defines the size of the dataset to generate (in GB)") | ||
| opt[String]('l', "location") | ||
| .action((x, c) => c.copy(location = x)) | ||
| .text("root directory of location to create data in") | ||
| opt[String]('f', "format") | ||
| .action((x, c) => c.copy(format = x)) | ||
| .text("valid spark format, Parquet, ORC ...") | ||
| opt[Boolean]('i', "useDoubleForDecimal") | ||
| .action((x, c) => c.copy(useDoubleForDecimal = x)) | ||
| .text("true to replace DecimalType with DoubleType") | ||
| opt[Boolean]('e', "useStringForDate") | ||
| .action((x, c) => c.copy(useStringForDate = x)) | ||
| .text("true to replace DateType with StringType") | ||
| opt[Boolean]('o', "overwrite") | ||
| .action((x, c) => c.copy(overwrite = x)) | ||
| .text("overwrite the data that is already there") | ||
| opt[Boolean]('p', "partitionTables") | ||
| .action((x, c) => c.copy(partitionTables = x)) | ||
| .text("create the partitioned fact tables") | ||
| opt[Boolean]('c', "clusterByPartitionColumns") | ||
| .action((x, c) => c.copy(clusterByPartitionColumns = x)) | ||
| .text("shuffle to get partitions coalesced into single files") | ||
| opt[Boolean]('v', "filterOutNullPartitionValues") | ||
| .action((x, c) => c.copy(filterOutNullPartitionValues = x)) | ||
| .text("true to filter out the partition with NULL key value") | ||
| opt[String]('t', "tableFilter") | ||
| .action((x, c) => c.copy(tableFilter = x)) | ||
| .text("\"\" means generate all tables") | ||
| opt[Int]('n', "numPartitions") | ||
| .action((x, c) => c.copy(numPartitions = x)) | ||
| .text("how many dsdgen partitions to run - number of input tasks.") | ||
| help("help") | ||
| .text("prints this usage text") | ||
| } | ||
|
|
||
| parser.parse(args, GenTPCDSDataConfig()) match { | ||
| case Some(config) => | ||
| run(config) | ||
| case None => | ||
| System.exit(1) | ||
| } | ||
| } | ||
|
|
||
| private def run(config: GenTPCDSDataConfig) { | ||
| val spark = SparkSession | ||
| .builder() | ||
| .appName(getClass.getName) | ||
| .master(config.master) | ||
| .getOrCreate() | ||
|
|
||
| val tables = new TPCDSTables(spark.sqlContext, | ||
| dsdgenDir = config.dsdgenDir, | ||
| scaleFactor = config.scaleFactor, | ||
| useDoubleForDecimal = config.useDoubleForDecimal, | ||
| useStringForDate = config.useStringForDate) | ||
|
|
||
| tables.genData( | ||
| location = config.location, | ||
| format = config.format, | ||
| overwrite = config.overwrite, | ||
| partitionTables = config.partitionTables, | ||
| clusterByPartitionColumns = config.clusterByPartitionColumns, | ||
| filterOutNullPartitionValues = config.filterOutNullPartitionValues, | ||
| tableFilter = config.tableFilter, | ||
| numPartitions = config.numPartitions) | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.