Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AngersZhuuuu committed Oct 24, 2023
1 parent 0e6f6df commit bc65abd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ object ObjectType extends Enumeration {
case PrivilegeObjectType.DATABASE => DATABASE
case PrivilegeObjectType.TABLE_OR_VIEW if obj.columns.nonEmpty => COLUMN
case PrivilegeObjectType.TABLE_OR_VIEW if opType.toString.contains("VIEW") => VIEW
case PrivilegeObjectType.TABLE_OR_VIEW if opType.toString.contains("INDEX") => INDEX
case PrivilegeObjectType.TABLE_OR_VIEW => TABLE
case PrivilegeObjectType.FUNCTION => FUNCTION
case PrivilegeObjectType.INDEX => INDEX
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package org.apache.kyuubi.plugin.spark.authz

import javax.annotation.Nonnull

import org.apache.kyuubi.plugin.spark.authz.OperationType._
import org.apache.kyuubi.plugin.spark.authz.PrivilegeObjectActionType.PrivilegeObjectActionType
import org.apache.kyuubi.plugin.spark.authz.PrivilegeObjectType._
import org.apache.kyuubi.plugin.spark.authz.serde.{Database, Function, Table}
Expand Down Expand Up @@ -65,28 +64,15 @@ object PrivilegeObject {
def apply(
table: Table,
columns: Seq[String] = Nil,
actionType: PrivilegeObjectActionType = PrivilegeObjectActionType.OTHER,
operationType: OperationType = QUERY): PrivilegeObject = {
operationType match {
case ALTERINDEX_REBUILD | CREATEINDEX | DROPINDEX | SHOWINDEXES =>
new PrivilegeObject(
INDEX,
actionType,
table.database.orNull,
table.table,
columns,
table.owner,
table.catalog)
case _ =>
new PrivilegeObject(
TABLE_OR_VIEW,
actionType,
table.database.orNull,
table.table,
columns,
table.owner,
table.catalog)
}
actionType: PrivilegeObjectActionType = PrivilegeObjectActionType.OTHER): PrivilegeObject = {
new PrivilegeObject(
TABLE_OR_VIEW,
actionType,
table.database.orNull,
table.table,
columns,
table.owner,
table.catalog)
}

def apply(function: Function): PrivilegeObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ package org.apache.kyuubi.plugin.spark.authz
object PrivilegeObjectType extends Enumeration {
type PrivilegeObjectType = Value

val DATABASE, TABLE_OR_VIEW, FUNCTION, INDEX = Value
val DATABASE, TABLE_OR_VIEW, FUNCTION = Value
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object PrivilegesBuilder {
outputObjs: ArrayBuffer[PrivilegeObject],
spark: SparkSession): OperationType = {

def getTablePriv(tableDesc: TableDesc, opType: OperationType): Seq[PrivilegeObject] = {
def getTablePriv(tableDesc: TableDesc): Seq[PrivilegeObject] = {
try {
val maybeTable = tableDesc.extract(plan, spark)
maybeTable match {
Expand All @@ -151,7 +151,7 @@ object PrivilegesBuilder {
} else {
val actionType = tableDesc.actionTypeDesc.map(_.extract(plan)).getOrElse(OTHER)
val columnNames = tableDesc.columnDesc.map(_.extract(plan)).getOrElse(Nil)
Seq(PrivilegeObject(newTable, columnNames, actionType, opType))
Seq(PrivilegeObject(newTable, columnNames, actionType))
}
case None => Nil
}
Expand Down Expand Up @@ -184,9 +184,9 @@ object PrivilegesBuilder {
val spec = TABLE_COMMAND_SPECS(classname)
spec.tableDescs.foreach { td =>
if (td.isInput) {
inputObjs ++= getTablePriv(td, spec.operationType)
inputObjs ++= getTablePriv(td)
} else {
outputObjs ++= getTablePriv(td, spec.operationType)
outputObjs ++= getTablePriv(td)
}
}
spec.queries(plan).foreach(buildQuery(_, inputObjs, spark = spark))
Expand Down

0 comments on commit bc65abd

Please sign in to comment.