AngersZhuuuu commented on code in PR #5787:
URL: https://github.com/apache/kyuubi/pull/5787#discussion_r1409250280
##########
extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/PrivilegesBuilderSuite.scala:
##########
@@ -987,7 +987,7 @@ abstract class PrivilegesBuilderSuite extends AnyFunSuite
}
test("Query: Literal") {
- checkColumns(s"select 1 from $reusedTable", Nil)
+ checkColumns(s"select 1 from $reusedTable", Seq("key", "value"))
Review Comment:
We only change the behavior here since it's a similar behavior like
```
SELECT count(1) from table
```
In current code, this count query return privilege of all columns of the
table.
But `test("Query: Literal")` won't return any column, the behavior is not
different.
In this pr, we unify the behavior.
If want to fallback the origin behavior of `test("Query: Literal")`
we can write `buildQuery()` as below
```
// If current plan's references don't have relation to it's input,
have two case
// 1. Such as `MapInPandas`, `ScriptTransformation`
// 2. Project output only have constant value
// For case 1, we should pass it's input as projection list
// since it's children's columns was pruned.
// For case too, we just skip.
if (columnPrune(p.references.toSeq ++ p.output,
p.inputSet).isEmpty) {
// If plan is project and output don't have relation to input,
can ignore.
if (!p.isInstanceOf[Project]) {
buildQuery(
child,
privilegeObjects,
p.inputSet.map(_.toAttribute).toSeq,
Nil,
spark)
}
} else {
buildQuery(
child,
privilegeObjects,
columnPrune(projectionList ++ p.references.toSeq,
p.inputSet).distinct,
conditionList ++ p.references,
spark)
}
```
If write code like this, also all `count(1)` `count(*)` query won't return
privilege.
cc @yaooqinn
--
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]