You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "cxzl25 (via GitHub)" <gi...@apache.org> on 2024/01/04 11:02:37 UTC
Re: [PR] [KYUUBI #5377][FOLLOWUP] Improvements and delete result on exit for saving result data file in Spark Engine [kyuubi]
cxzl25 commented on code in PR #5923:
URL: https://github.com/apache/kyuubi/pull/5923#discussion_r1441614229
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/ExecuteStatement.scala:
##########
@@ -178,23 +174,29 @@ class ExecuteStatement(
resultSaveThreshold,
result)) {
val sessionId = session.handle.identifier.toString
- val savePath = session.sessionManager.getConf.get(OPERATION_RESULT_SAVE_TO_FILE_DIR)
- 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 codec = 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", codec).format("orc").save(saveFileName.get)
- } else {
- result.toDF(colName: _*).write
- .option("compression", codec).format("orc").save(saveFileName.get)
+ saveFileName = {
+ val resultSaveToDir =
+ session.sessionManager.getConf.get(OPERATION_RESULT_SAVE_TO_FILE_DIR)
+ Some(s"$resultSaveToDir/$engineId/$sessionId/$statementId")
}
- info(s"Save result to $saveFileName")
+ Utils.addShutdownHook(() => cleanupSavedResultFile())
Review Comment:
After the engine exits, the entire directory will be cleaned, which is more efficient than cleaning files one by one.
If you want to clean up the query results quickly, I suggest deleting it directly in the close method.
https://github.com/apache/kyuubi/blob/4cceb1dbd72ec9d6ac0c9dc9a5b2b21f0600ba9b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala#L94-L101
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org