Skip to content

Commit eb7ad51

Browse files
yaooqinnulysses-you
authored andcommitted
[KYUUBI #2390] RuleEliminateMarker stays in analyze phase for data masking
### _Why are the changes needed?_ Avoid creating duplicate data masking projection to prevent errors in #2390 ### _How was this patch tested?_ - [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #2394 from yaooqinn/2390. Closes #2390 31c5d07 [Kent Yao] [KYUUBI #2390] RuleEliminateMarker stays in analyze phase for data masking ad0138c [Kent Yao] [KYUUBI #2390] RuleEliminateMarker stays in analyze phase for data masking Authored-by: Kent Yao <yao@apache.org> Signed-off-by: ulysses-you <ulyssesyou@apache.org>
1 parent 8f29b4f commit eb7ad51

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RangerSparkExtension.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class RangerSparkExtension extends (SparkSessionExtensions => Unit) {
4040

4141
override def apply(v1: SparkSessionExtensions): Unit = {
4242
v1.injectResolutionRule(new RuleApplyRowFilterAndDataMasking(_))
43-
v1.injectPostHocResolutionRule(_ => new RuleEliminateMarker())
43+
v1.injectOptimizerRule(_ => new RuleEliminateMarker())
4444
v1.injectOptimizerRule(new RuleAuthorization(_))
4545
}
4646
}

extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RangerSparkExtensionSuite.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,26 @@ abstract class RangerSparkExtensionSuite extends KyuubiFunSuite with SparkSessio
235235
doAs("admin", sql(s"DROP TABLE IF EXISTS $db.$table"))
236236
}
237237
}
238+
239+
test("KYUUBI #2390: RuleEliminateMarker stays in analyze phase for data masking") {
240+
val db = "default"
241+
val table = "src"
242+
val create =
243+
s"CREATE TABLE IF NOT EXISTS $db.$table (key int, value1 int) USING $format"
244+
try {
245+
doAs("admin", sql(create))
246+
doAs("admin", sql(s"INSERT INTO $db.$table SELECT 1, 1"))
247+
// scalastyle: off
248+
doAs(
249+
"bob", {
250+
assert(sql(s"select * from $db.$table").collect() ===
251+
Seq(Row(1, DigestUtils.md5Hex("1"))))
252+
assert(Try(sql(s"select * from $db.$table").show(1)).isSuccess)
253+
})
254+
} finally {
255+
doAs("admin", sql(s"DROP TABLE IF EXISTS $db.$table"))
256+
}
257+
}
238258
}
239259

240260
class InMemoryCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {

0 commit comments

Comments
 (0)