-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32481][CORE][SQL] Support truncate table to move data to trash #29552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ import com.google.common.net.InetAddresses | |
| import org.apache.commons.codec.binary.Hex | ||
| import org.apache.commons.lang3.SystemUtils | ||
| import org.apache.hadoop.conf.Configuration | ||
| import org.apache.hadoop.fs.{FileSystem, FileUtil, Path} | ||
| import org.apache.hadoop.fs.{FileSystem, FileUtil, Path, Trash} | ||
| import org.apache.hadoop.io.compress.{CompressionCodecFactory, SplittableCompressionCodec} | ||
| import org.apache.hadoop.security.UserGroupInformation | ||
| import org.apache.hadoop.yarn.conf.YarnConfiguration | ||
|
|
@@ -269,6 +269,27 @@ private[spark] object Utils extends Logging { | |
| file.setExecutable(true, true) | ||
| } | ||
|
|
||
| /** | ||
| * Move data to trash if 'spark.sql.truncate.trash.enabled' is true | ||
| */ | ||
| def moveToTrashIfEnabled( | ||
| fs: FileSystem, | ||
| partitionPath: Path, | ||
| isTrashEnabled: Boolean, | ||
| hadoopConf: Configuration): Boolean = { | ||
|
||
| if (isTrashEnabled) { | ||
| logDebug(s"will move data ${partitionPath.toString} to trash") | ||
Udbhav30 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| val isSuccess = Trash.moveToAppropriateTrash(fs, partitionPath, hadoopConf) | ||
| if (!isSuccess) { | ||
| logWarning(s"Failed to move data ${partitionPath.toString} to trash") | ||
Udbhav30 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return fs.delete(partitionPath, true) | ||
| } | ||
| isSuccess | ||
| } else { | ||
| fs.delete(partitionPath, true) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Create a directory given the abstract pathname | ||
| * @return true, if the directory is successfully created; otherwise, return false. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.