[KYUUBI #5189] [AUTHZ] Make spark authz module compilable on Scala 2.13

### _Why are the changes needed?_

- Make spark authz module compilable on Scala 2.13

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [ ] [Run test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests) locally before make a pull request

### _Was this patch authored or co-authored using generative AI tooling?_

No.

Closes #5189 from bowenliang123/scala213-authz.

Closes #5189

c5ee61a24 [liangbowen] adapt spark authz module to 2.13

Authored-by: liangbowen <liangbowen@gf.com.cn>
Signed-off-by: liangbowen <liangbowen@gf.com.cn>
This commit is contained in:
liangbowen 2023-08-23 08:41:46 +08:00
parent 0b1a0cb4f2
commit 5de3a40690
5 changed files with 10 additions and 10 deletions

View File

@ -209,7 +209,7 @@ object PrivilegesBuilder {
}
}
type PrivilegesAndOpType = (Seq[PrivilegeObject], Seq[PrivilegeObject], OperationType)
type PrivilegesAndOpType = (Iterable[PrivilegeObject], Iterable[PrivilegeObject], OperationType)
/**
* Build input privilege objects from a Spark's LogicalPlan for hive permanent udf

View File

@ -53,7 +53,7 @@ object RuleAuthorization {
requests += AccessRequest(resource, ugi, opType, AccessType.USE)
}
def addAccessRequest(objects: Seq[PrivilegeObject], isInput: Boolean): Unit = {
def addAccessRequest(objects: Iterable[PrivilegeObject], isInput: Boolean): Unit = {
objects.foreach { obj =>
val resource = AccessResource(obj, opType)
val accessType = ranger.AccessType(obj, opType, isInput)
@ -84,7 +84,7 @@ object RuleAuthorization {
}
case _ => Seq(request)
}
}
}.toSeq
if (authorizeInSingleCall) {
verify(requestArrays.flatten, auditHandler)

View File

@ -33,7 +33,7 @@ trait SparkSessionProvider {
protected val catalogImpl: String
protected def format: String = if (catalogImpl == "hive") "hive" else "parquet"
protected val extension: SparkSessionExtensions => Unit = _ => Unit
protected val extension: SparkSessionExtensions => Unit = _ => ()
protected val sqlExtensions: String = ""
protected val extraSparkConf: SparkConf = new SparkConf()

View File

@ -670,7 +670,7 @@ abstract class V2CommandsPrivilegesSuite extends PrivilegesBuilderSuite {
val spec = DB_COMMAND_SPECS(plan1.getClass.getName)
var db: Database = null
spec.databaseDescs.find { d =>
Try(db = d.extract(plan1)).isSuccess
Try { db = d.extract(plan1) }.isSuccess
}
withClue(sql1) {
assert(db.catalog === None)

View File

@ -79,7 +79,7 @@ class V2JdbcTableCatalogPrivilegesBuilderSuite extends V2CommandsPrivilegesSuite
val spec = TABLE_COMMAND_SPECS(plan.getClass.getName)
var table: Table = null
spec.tableDescs.find { d =>
Try(table = d.extract(plan, spark).get).isSuccess
Try { table = d.extract(plan, spark).get }.isSuccess
}
withClue(str) {
assertEqualsIgnoreCase(Some(catalogV2))(table.catalog)
@ -104,7 +104,7 @@ class V2JdbcTableCatalogPrivilegesBuilderSuite extends V2CommandsPrivilegesSuite
val spec = TABLE_COMMAND_SPECS(plan.getClass.getName)
var table: Table = null
spec.tableDescs.find { d =>
Try(table = d.extract(plan, spark).get).isSuccess
Try { table = d.extract(plan, spark).get }.isSuccess
}
withClue(sql1) {
assertEqualsIgnoreCase(Some(catalogV2))(table.catalog)
@ -127,7 +127,7 @@ class V2JdbcTableCatalogPrivilegesBuilderSuite extends V2CommandsPrivilegesSuite
val plan = executePlan(sql1).analyzed
val spec = TABLE_COMMAND_SPECS(plan.getClass.getName)
var table: Table = null
spec.tableDescs.find { d => Try(table = d.extract(plan, spark).get).isSuccess }
spec.tableDescs.find { d => Try { table = d.extract(plan, spark).get }.isSuccess }
withClue(sql1) {
assertEqualsIgnoreCase(Some(catalogV2))(table.catalog)
assertEqualsIgnoreCase(Some(ns1))(table.database)
@ -146,7 +146,7 @@ class V2JdbcTableCatalogPrivilegesBuilderSuite extends V2CommandsPrivilegesSuite
val spec = DB_COMMAND_SPECS(plan.getClass.getName)
var db: Database = null
spec.databaseDescs.find { d =>
Try(db = d.extract(plan)).isSuccess
Try { db = d.extract(plan) }.isSuccess
}
withClue(sql) {
assertEqualsIgnoreCase(Some(catalogV2))(db.catalog)
@ -165,7 +165,7 @@ class V2JdbcTableCatalogPrivilegesBuilderSuite extends V2CommandsPrivilegesSuite
val spec = DB_COMMAND_SPECS(plan.getClass.getName)
var db: Database = null
spec.databaseDescs.find { d =>
Try(db = d.extract(plan)).isSuccess
Try { db = d.extract(plan) }.isSuccess
}
withClue(sql1) {
assertEqualsIgnoreCase(Some(catalogV2))(db.catalog)