Skip to content

Commit a2df53b

Browse files
committed
Review comments fix
1 parent 8848b3f commit a2df53b

File tree

3 files changed

+6
-4
lines changed
  • core/src/main/scala/org/apache/spark/util
  • sql
    • catalyst/src/main/scala/org/apache/spark/sql/internal
    • core/src/test/scala/org/apache/spark/sql/execution/command

3 files changed

+6
-4
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,20 +270,21 @@ private[spark] object Utils extends Logging {
270270
}
271271

272272
/**
273-
* Move data to trash on truncate table given
274-
* 'spark.sql.truncate.trash.enabled' is true
273+
* Move data to trash if 'spark.sql.truncate.trash.enabled' is true
275274
*/
276275
def moveToTrashIfEnabled(
277276
fs: FileSystem,
278277
partitionPath: Path,
279278
isTrashEnabled: Boolean,
280-
hadoopConf: Configuration): Unit = {
279+
hadoopConf: Configuration): Boolean = {
281280
if (isTrashEnabled) {
282281
logDebug(s"will move data ${partitionPath.toString} to trash")
283282
val isSuccess = Trash.moveToAppropriateTrash(fs, partitionPath, hadoopConf)
284283
if (!isSuccess) {
285284
logWarning(s"Failed to move data ${partitionPath.toString} to trash")
285+
return fs.delete(partitionPath, true)
286286
}
287+
isSuccess
287288
} else {
288289
fs.delete(partitionPath, true)
289290
}

sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,6 +2729,7 @@ object SQLConf {
27292729
"fs.trash.interval, and in default, the server side configuration value takes " +
27302730
"precedence over the client-side one. Note that if fs.trash.interval is non-positive, " +
27312731
"this will be a no-op and log a warning message.")
2732+
.version("3.1.0")
27322733
.booleanConf
27332734
.createWithDefault(false)
27342735

sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,7 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
31573157
}
31583158
}
31593159

3160-
test("SPARK-32481 Donot move data to trash on truncate table if disabled") {
3160+
test("SPARK-32481 Do not move data to trash on truncate table if disabled") {
31613161
withTable("tab1") {
31623162
withSQLConf(SQLConf.TRUNCATE_TRASH_ENABLED.key -> "false") {
31633163
sql("CREATE TABLE tab1 (col INT) USING parquet")

0 commit comments

Comments
 (0)