Github user wangyum commented on a diff in the pull request: https://github.com/apache/spark/pull/22078#discussion_r209934062 --- 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 -- These code copy from https://github.com/apache/hive/blob/rel/release-1.2.2/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java#L722-L767 I will think about whether there is a better implementation.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org