Skip to content

Commit

Permalink
use zlib when SPARK version less than 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lsm1 committed Dec 20, 2023
1 parent e2d9a8e commit 31d4fc1
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,19 @@ class ExecuteStatement(
saveFileName = Some(s"$savePath/$engineId/$sessionId/$statementId")
// Rename all col name to avoid duplicate columns
val colName = range(0, result.schema.size).map(x => "col" + x)

val compress = if (SPARK_ENGINE_RUNTIME_VERSION >= "3.2") {
"zstd"
} else {
"zlib"
}
// df.write will introduce an extra shuffle for the outermost limit, and hurt performance
if (resultMaxRows > 0) {
result.toDF(colName: _*).limit(resultMaxRows).write
.option("compression", "zstd").format("orc").save(saveFileName.get)
.option("compression", compress).format("orc").save(saveFileName.get)
} else {
result.toDF(colName: _*).write
.option("compression", "zstd").format("orc").save(saveFileName.get)
.option("compression", compress).format("orc").save(saveFileName.get)
}
info(s"Save result to $saveFileName")
fetchOrcStatement = Some(new FetchOrcStatement(spark))
Expand Down

0 comments on commit 31d4fc1

Please sign in to comment.