Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.kyuubi.plugin.spark.authz.OperationType.OperationType
import org.apache.kyuubi.plugin.spark.authz.PrivilegeObjectActionType._
import org.apache.kyuubi.plugin.spark.authz.serde._
import org.apache.kyuubi.plugin.spark.authz.util.AuthZUtils._
import org.apache.kyuubi.plugin.spark.authz.util.PermanentViewMarker
import org.apache.kyuubi.util.reflect.ReflectUtils._

object PrivilegesBuilder {
Expand Down Expand Up @@ -102,6 +103,11 @@ object PrivilegesBuilder {
val cols = conditionList ++ aggCols
buildQuery(a.child, privilegeObjects, projectionList, cols, spark)

case pvm: PermanentViewMarker =>
getScanSpec(pvm).tables(pvm, spark).foreach { table =>
privilegeObjects += PrivilegeObject(table, pvm.visitColNames)
}

case scan if isKnownScan(scan) && scan.resolved =>
getScanSpec(scan).tables(scan, spark).foreach(mergeProjection(_, scan))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ class RuleApplyPermanentViewMarker extends Rule[LogicalPlan] {
// TODO: Currently, we do not do an auth check in the subquery
// as the main query part also secures it. But for performance consideration,
// we also pre-check it in subqueries and fail fast with negative privileges.
subquery.withNewPlan(plan = PermanentViewMarker(subquery.plan, null))
subquery.withNewPlan(plan =
PermanentViewMarker(
subquery.plan,
permanentView.desc,
permanentView.output.map(_.name)))
}
PermanentViewMarker(resolvedSubquery, resolvedSubquery.desc)
PermanentViewMarker(
resolvedSubquery,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's not resolvedSubquery but a view?

resolvedSubquery.desc,
resolvedSubquery.output.map(_.name))
case other => apply(other)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import org.apache.spark.sql.catalyst.catalog.CatalogTable
import org.apache.spark.sql.catalyst.expressions.Attribute
import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, UnaryNode}

case class PermanentViewMarker(child: LogicalPlan, catalogTable: CatalogTable) extends UnaryNode
case class PermanentViewMarker(
child: LogicalPlan,
catalogTable: CatalogTable,
visitColNames: Seq[String]) extends UnaryNode
with WithInternalChild {

override def output: Seq[Attribute] = child.output
Expand Down