File tree Expand file tree Collapse file tree 3 files changed +6
-4
lines changed
core/src/main/scala/org/apache/spark/util
catalyst/src/main/scala/org/apache/spark/sql/internal
core/src/test/scala/org/apache/spark/sql/execution/command Expand file tree Collapse file tree 3 files changed +6
-4
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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" )
You can’t perform that action at this time.
0 commit comments