viirya commented on a change in pull request #26956: [SPARK-30312][SQL]
Preserve path permission and acl when truncate table
URL: https://github.com/apache/spark/pull/26956#discussion_r362625771
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
##########
@@ -499,8 +499,35 @@ case class TruncateTableCommand(
val path = new Path(location.get)
try {
val fs = path.getFileSystem(hadoopConf)
+ val fileStatus = fs.getFileStatus(path)
+ // Not all fs impl. support these APIs.
+ val optPermission = Try(fileStatus.getPermission())
+ val optAcls = Try(fs.getAclStatus(path).getEntries)
+
fs.delete(path, true)
Review comment:
For Hive, I try to trace the code path for TRUNCATE TABLE:
1. HiveMetaStore. truncateTableInternal:
Get the locations of table/partitions and call Warehouse.deleteDir for each.
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java#L3109
2. Warehouse.deleteDir delegates to MetaStoreFS.deleteDir.
3. HiveMetaStoreFsImpl (implements MetaStoreFS) delegates to
FileUtils.moveToTrash which calls `FileSystem.delete(f, true)`.
In `HiveMetaStore.truncateTableInternal`, after the location is deleted, new
directory is created and previous file status including permissions, group, and
ACLs are set to new directory:
https://github.com/apache/hive/blob/35f86c749cefc2a9972a991deed78a1c3719093d/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java#L288
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]