maropu commented on a change in pull request #26977: [SPARK-30326][SQL] Raise 
exception if analyzer exceed max iterations
URL: https://github.com/apache/spark/pull/26977#discussion_r364206366
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
 ##########
 @@ -737,4 +756,23 @@ class AnalysisSuite extends AnalysisTest with Matchers {
       CollectMetrics("evt1", count :: Nil, tblB))
     assertAnalysisError(query, "Multiple definitions of observed metrics" :: 
"evt1" :: Nil)
   }
+
+  test("Analysis exceed max iterations") {
+    // RuleExecutor only throw exception or log warning when the rule is 
supposed to run
+    // more than once.
+    val maxIterations = 2
+    val conf = new SQLConf().copy(SQLConf.ANALYZER_MAX_ITERATIONS -> 
maxIterations)
 
 Review comment:
   I think its ok to inline the analyzer like this;
   ```
     test("Analysis exceed max iterations") {
       // RuleExecutor only throw exception or log warning when the rule is 
supposed to run
       // more than once.
       val maxIterations = 2
       val testAnalyzer = new Analyzer(
         new SessionCatalog(new InMemoryCatalog, FunctionRegistry.builtin, 
conf),
         new SQLConf().copy(SQLConf.ANALYZER_MAX_ITERATIONS -> maxIterations))
   
       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 message = intercept[TreeNodeException[LogicalPlan]] {
         testAnalyzer.execute(plan)
       }.getMessage
       assert(message.startsWith(s"Max iterations ($maxIterations) reached for 
batch Resolution"))
     }
   ```

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to