uros-b commented on code in PR #58674:
URL: https://github.com/apache/spark/pull/58674#discussion_r3983057049
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/RestrictedModeSuite.scala:
##########
@@ -137,4 +139,31 @@ class RestrictedModeSuite extends AnalysisTest {
checkRestrictedError(e, "The TRANSFORM ... USING clause")
}
}
+
+ test("restricted mode rejects banned functions nested in subqueries") {
+ Seq("reflect", "java_method", "try_reflect").foreach { fn =>
+ withRestrictedMode(true) {
+ val analyzer = getAnalyzer
+ val e = intercept[AnalysisException] {
+ analyzer.checkAnalysis(analyzer.execute(
+ Filter(Exists(functionProject(fn)), TestRelations.testRelation)))
+ }
+ checkRestrictedError(e, s"The `$fn` function")
+ }
+ }
+ withRestrictedMode(true) {
+ val analyzer = getAnalyzer
+ val e = intercept[AnalysisException] {
+ analyzer.checkAnalysis(analyzer.execute(Project(
+ Seq(UnresolvedAlias(ScalarSubquery(functionProject("reflect")))),
+ TestRelations.testRelation)))
+ }
+ checkRestrictedError(e, "The `reflect` function")
+ }
+ withRestrictedMode(false) {
+ val analyzer = getAnalyzer
+ analyzer.checkAnalysis(analyzer.execute(
+ Filter(Exists(functionProject("reflect")),
TestRelations.testRelation)))
+ }
+ }
Review Comment:
RestrictedModeSuite.scala (new test) & PR body -- Overlap re-confirmed
against current master: the sibling `RestrictedModeCommandSuite` (sql/core)
still has `"restricted mode reaches a feature nested inside a scalar subquery"`
(`SELECT (SELECT reflect(...)) AS c`) plus `"restricted mode allows deeply
nested subqueries..."` (40-deep), both driving the same `SubqueryExpression =>
checkPlan(s.plan)` branch through real SQL. So the body's "zero coverage" / "a
regression would fail silently (every existing test stays green)" framing is
repo-wide inaccurate, and the new unit scalar-subquery case duplicates that
sql/core coverage. Narrow the justification to the catalyst suite
`RestrictedModeSuite`, and trim or re-focus the scalar case onto the
genuinely-new shapes: the `EXISTS` predicate (all three functions) and
`java_method`/`try_reflect` nested in a subquery, which no suite covers.
--
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]