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

Initial support for Data Maintenance #9

Merged
merged 21 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 nds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ optional arguments:
--iceberg_write_format {parquet,orc,avro}
File format for the Iceberg table; parquet, avro, or orc
--compression COMPRESSION
Compression codec when saving Parquet Orc or Iceberg data. Iceberg is using gzip as default but spark-rapids plugin does not support it yet, so default it to snappy. Please refer to https://iceberg.apache.org/docs/latest/configuration/#write-properties for
supported codec for different output format such as Parquet or Avro in Iceberg. Please refer to https://spark.apache.org/docs/latest/sql-data-sources.html for supported codec when writing Parquet Orc or Avro by Spark. Default is Snappy.
Compression codec when saving Parquet Orc or Iceberg data. Please refer to https://iceberg.apache.org/docs/latest/configuration/#write-properties for supported codec for different output format such as Parquet or Avro in Iceberg. Please refer to
https://spark.apache.org/docs/latest/sql-data-sources.html for supported codec when writing Parquet Orc or Avro by Spark. When not specified, it will use Spark or Iceberg default ones.
wjxiz1992 marked this conversation as resolved.
Show resolved Hide resolved

```

Expand Down
32 changes: 19 additions & 13 deletions nds/nds_transcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def get_schemas(use_decimal):
StructField("sr_store_sk", IntegerType()),
StructField("sr_reason_sk", IntegerType()),
# Use LongType due to https://github.com/NVIDIA/spark-rapids-benchmarks/pull/9#issuecomment-1138379596
# Databricks is using LongType as well in their accepeted benchmark reports.
# Databricks is using LongType as well in their accepted benchmark reports.
# See https://www.tpc.org/results/supporting_files/tpcds/databricks~tpcds~100000~databricks_SQL_8.3~sup-1~2021-11-02~v01.zip
StructField("sr_ticket_number", LongType(), nullable=False),
StructField("sr_return_quantity", IntegerType()),
Expand Down Expand Up @@ -748,7 +748,7 @@ def store(session, df, filename, output_format, output_mode, iceberg_write_forma
output_format (str): parquet, orc or avro
write_mode (str): save modes as defined by "https://spark.apache.org/docs/latest/sql-data-sources-load-save-functions.html#save-modes.
use_iceberg (bool): write data into Iceberg tables
compression (str): Parquet compression codec when saving Iceberg tables
compression (str): compression codec for converted data when saving to disk
prefix (str): output data path when not using Iceberg.
"""
if output_format == "iceberg":
Expand All @@ -764,10 +764,12 @@ def store(session, df, filename, output_format, output_mode, iceberg_write_forma
df.coalesce(1).createOrReplaceTempView("temptbl")
CTAS += f" tblproperties('write.format.default' = '{iceberg_write_format}'"
# Iceberg now only support compression codec option for Parquet and Avro write.
if iceberg_write_format == "parquet":
CTAS += f", 'write.parquet.compression-codec' = '{compression}')"
elif iceberg_write_format == "avro":
CTAS += f", 'write.avro.compression-codec' = '{compression}')"
if compression:
if iceberg_write_format == "parquet":
CTAS += f", 'write.parquet.compression-codec' = '{compression}'"
elif iceberg_write_format == "avro":
CTAS += f", 'write.avro.compression-codec' = '{compression}'"
CTAS += ")"
CTAS += " as select * from temptbl"
session.sql(CTAS)
else:
Expand All @@ -776,11 +778,16 @@ def store(session, df, filename, output_format, output_mode, iceberg_write_forma
df = df.repartition(
col(TABLE_PARTITIONING[filename])).sortWithinPartitions(
TABLE_PARTITIONING[filename])
df.write.option('compression', compression).format(output_format).mode(
writer = df.write
if compression:
writer = writer.option('compression', compression)
writer.format(output_format).mode(
output_mode).partitionBy(TABLE_PARTITIONING[filename]).save(data_path)
else:
df.coalesce(1).write.option('compression', compression).format(
output_format).mode(output_mode).save(data_path)
writer = df.coalesce(1).write
if compression:
writer = writer.option('compression', compression)
writer.format(output_format).mode(output_mode).save(data_path)

def transcode(args):
session = pyspark.sql.SparkSession.builder \
Expand Down Expand Up @@ -886,13 +893,12 @@ def transcode(args):
)
parser.add_argument(
'--compression',
default='snappy',
help='Compression codec when saving Parquet Orc or Iceberg data. Iceberg is using gzip as' +
' default but spark-rapids plugin does not support it yet, so default it to snappy.' +
help='Compression codec when saving Parquet Orc or Iceberg data.' +
' Please refer to https://iceberg.apache.org/docs/latest/configuration/#write-properties ' +
' for supported codec for different output format such as Parquet or Avro in Iceberg.' +
' Please refer to https://spark.apache.org/docs/latest/sql-data-sources.html' +
' for supported codec when writing Parquet Orc or Avro by Spark. Default is Snappy.'
' for supported codec when writing Parquet Orc or Avro by Spark.' +
' When not specified, it will use Spark or Iceberg default ones.'
)
args = parser.parse_args()
transcode(args)
9 changes: 5 additions & 4 deletions nds/tpcds-gen/src/main/java/org/notmysock/tpcds/GenTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ public int run(String[] args) throws Exception {
Integer update = null;
if(line.hasOption("update")) {
update = Integer.parseInt(line.getOptionValue("update"));
if(update < 0) {
// TPC-DS will error if update is < 0
System.err.println("The update value cannot be less than 0, your input: " + update);
}
}

if(update != null && update < 0) {
// TPC-DS will error if update is < 0
System.err.println("The update value cannot be less than 0, your input: " + update);
}


if(parallel == 1 || scale == 1) {
System.err.println("The MR task does not work for scale=1 or parallel=1");
Expand Down