vrjdev commented on code in PR #58674:
URL: https://github.com/apache/spark/pull/58674#discussion_r3983957741


##########
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:
   Updated the tests based on the comment.



-- 
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]

Reply via email to