Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AngersZhuuuu committed Nov 2, 2023
1 parent d4bb5b4 commit a71f3a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CatalogStorageFormatURIExtractor extends URIExtractor {
}

class HadoopFsRelationFileIndexURIExtractor extends URIExtractor {
override def apply(v1: AnyRef): Option[Uri] = {
Some(Uri(v1.asInstanceOf[HadoopFsRelation].location.rootPaths.map(_.toString).mkString(",")))
override def apply(v1: AnyRef): Seq[Uri] = {
v1.asInstanceOf[HadoopFsRelation].location.rootPaths.map(_.toString).map(Uri)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package org.apache.kyuubi.plugin.spark.authz.ranger

import java.nio.file.Path

import scala.reflect.io.File
import scala.util.Try

import org.apache.hadoop.security.UserGroupInformation
Expand Down Expand Up @@ -1090,26 +1089,23 @@ class HiveCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
test("HadoopFsRelation") {
val db1 = defaultDb
val table1 = "table1"
val tableDirectory = getClass.getResource("/").getPath + "table_directory"
val directory = File(tableDirectory).createDirectory()
withSingleCallEnabled {
withCleanTmpResources(Seq((s"$db1.$table1", "table"))) {
doAs(admin, sql(s"CREATE TABLE IF NOT EXISTS $db1.$table1 (id int, scope int)"))
doAs(
admin,
sql(
s"""
|INSERT OVERWRITE DIRECTORY '${directory.path}'
|USING parquet
|SELECT * FROM $db1.$table1""".stripMargin))
withTempDir { path =>
withSingleCallEnabled {
withCleanTmpResources(Seq((s"$db1.$table1", "table"))) {
doAs(admin, sql(s"CREATE TABLE IF NOT EXISTS $db1.$table1 (id int, scope int)"))
doAs(
admin,
sql(
s"""
|INSERT OVERWRITE DIRECTORY '$path'
|USING parquet
|SELECT * FROM $db1.$table1""".stripMargin))

interceptContains[AccessControlException](doAs(
someone,
sql(
s"""
|SELECT * FROM parquet.`${directory.path}`""".stripMargin).explain(true)))(
s"does not have [select] privilege on " +
s"[[file:${directory.path}, file:${directory.path}/]]")
interceptContains[AccessControlException](
doAs(someone, sql(s"SELECT * FROM parquet.`$path`".stripMargin).explain(true)))(
s"does not have [select] privilege on " +
s"[[file:$path, file:$path/]]")
}
}
}
}
Expand Down

0 comments on commit a71f3a6

Please sign in to comment.