Github user mgaido91 commented on a diff in the pull request:
https://github.com/apache/spark/pull/22078#discussion_r209859205
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelationCommand.scala
---
@@ -261,4 +273,67 @@ case class InsertIntoHadoopFsRelationCommand(
}
}.toMap
}
+
+ private def isExtendedAclEnabled(hadoopConf: Configuration): Boolean =
+ hadoopConf.getBoolean(DFS_NAMENODE_ACLS_ENABLED_KEY,
DFS_NAMENODE_ACLS_ENABLED_DEFAULT)
+
+ private def getFullFileStatus(
+ conf: SQLConf,
+ hadoopConf: Configuration,
+ fs: FileSystem,
+ file: Path): (String, FsPermission, AclStatus) = {
+ if (conf.isDataSouceTableInheritPerms && fs.exists(file)) {
+ val fileStatus = fs.getFileStatus(file)
+ val aclStatus = if (isExtendedAclEnabled(hadoopConf))
fs.getAclStatus(file) else null
+ (fileStatus.getGroup, fileStatus.getPermission, aclStatus)
+ } else {
+ (null, null, null)
+ }
+ }
+
+ private def setFullFileStatus(
+ hadoopConf: Configuration,
+ group: String,
+ permission: FsPermission,
+ aclStatus: AclStatus,
+ fs: FileSystem,
+ target: Path): Unit = {
+ try {
+ // use FsShell to change group, permissions, and extended ACL's
recursively
+ val fsShell = new FsShell
+ fsShell.setConf(hadoopConf)
+ fsShell.run(Array[String]("-chgrp", "-R", group, target.toString))
--- End diff --
can we avoid using the shell ad rather use the programmatic API? eg.
`fs.setOwner`.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]