yaooqinn commented on code in PR #2613:
URL: https://github.com/apache/incubator-kyuubi/pull/2613#discussion_r869839387
##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RuleReplaceShowObjectCommands.scala:
##########
@@ -55,6 +80,62 @@ case class FilteredShowTablesCommand(delegated:
RunnableCommand)
val result = SparkRangerAdminPlugin.isAccessAllowed(request)
result != null && result.getIsAllowed
}
+}
+
+case class FilteredShowNamespacesCommand(delegated: Any) extends
RunnableCommand
+ with WithInternalChild {
+
+ override def output: Seq[Attribute] = {
+ val clazz =
Class.forName("org.apache.spark.sql.execution.datasources.v2.V2CommandExec")
+ val outputMethod = clazz.getMethod("output")
+ val output = outputMethod.invoke(delegated)
+ output.asInstanceOf[Seq[Attribute]]
+ }
+
+ override def run(sparkSession: SparkSession): Seq[Row] = {
+ val runMethod = delegated.getClass.getMethod("run")
+ runMethod.setAccessible(true)
+ val rows = runMethod.invoke(delegated).asInstanceOf[Seq[InternalRow]]
+ val ugi = AuthZUtils.getAuthzUgi(sparkSession.sparkContext)
+ rows.filter(r => isAllowed(r, ugi)).map(r =>
+ Row.fromSeq(Seq.apply(r.getString(0).toString)))
Review Comment:
~.toString~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]