yuningzh-db commented on a change in pull request #30108:
URL: https://github.com/apache/spark/pull/30108#discussion_r511049304



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
##########
@@ -926,4 +926,45 @@ class AnalysisSuite extends AnalysisTest with Matchers {
     )
     assertAnalysisSuccess(plan)
   }
+
+  test("SPARK-33197: Make sure changes to ANALYZER_MAX_ITERATIONS take effect 
at runtime") {
+    // RuleExecutor only throw exception or log warning when the rule is 
supposed to run
+    // more than once.
+    val maxIterations = 2
+    val maxIterationsEnough = 5
+    withSQLConf(SQLConf.ANALYZER_MAX_ITERATIONS.key -> maxIterations.toString) 
{
+      val conf = SQLConf.get
+      val testAnalyzer = new Analyzer(
+        new SessionCatalog(new InMemoryCatalog, FunctionRegistry.builtin, 
conf), conf)
+
+      val plan = testRelation2.select(
+        $"a" / Literal(2) as "div1",
+        $"a" / $"b" as "div2",
+        $"a" / $"c" as "div3",
+        $"a" / $"d" as "div4",
+        $"e" / $"e" as "div5")
+
+      val message1 = intercept[TreeNodeException[LogicalPlan]] {
+        testAnalyzer.execute(plan)
+      }.getMessage
+      assert(message1.startsWith(s"Max iterations ($maxIterations) reached for 
batch Resolution, " +
+        s"please set '${SQLConf.ANALYZER_MAX_ITERATIONS.key}' to a larger 
value."))
+
+      withSQLConf(SQLConf.ANALYZER_MAX_ITERATIONS.key -> 
maxIterationsEnough.toString) {
+        try {
+          testAnalyzer.execute(plan)
+        } catch {

Review comment:
       I want to make it explicit that this line should not trigger exception.




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

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