Skip to content

Commit

Permalink
Handle review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Udbhav30 committed Aug 26, 2020
1 parent 6cf355a commit 84f7e95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ private[spark] object Utils extends Logging {
}

/**
* Move data to trash if 'spark.sql.truncate.trash.enabled' is true
* Move data to trash if 'spark.sql.truncate.trash.enabled' is true, else
* delete the data permanently. If move data to trash failed fallback to hard deletion.
*/
def moveToTrashIfEnabled(
fs: FileSystem,
Expand All @@ -281,7 +282,8 @@ private[spark] object Utils extends Logging {
logDebug(s"will move data ${partitionPath.toString} to trash")
val isSuccess = Trash.moveToAppropriateTrash(fs, partitionPath, hadoopConf)
if (!isSuccess) {
logWarning(s"Failed to move data ${partitionPath.toString} to trash")
logWarning(s"Failed to move data ${partitionPath.toString} to trash. " +
"Fallback to hard deletion")
return fs.delete(partitionPath, true)
}
isSuccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,8 @@ object SQLConf {
"to trash directory or deleted permanently. The trash retention time is controlled by " +
"fs.trash.interval, and in default, the server side configuration value takes " +
"precedence over the client-side one. Note that if fs.trash.interval is non-positive, " +
"this will be a no-op and log a warning message.")
"this will be a no-op and log a warning message. If the data fails to be moved to " +
"trash, Spark will turn to delete it permanently.")
.version("3.1.0")
.booleanConf
.createWithDefault(false)
Expand Down

0 comments on commit 84f7e95

Please sign in to comment.