maropu commented on a change in pull request #30108:
URL: https://github.com/apache/spark/pull/30108#discussion_r509797389
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
##########
@@ -926,4 +926,43 @@ 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
+ val conf = new SQLConf().copy(SQLConf.ANALYZER_MAX_ITERATIONS ->
maxIterations)
+ 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."))
+
+ conf.setConfString(SQLConf.ANALYZER_MAX_ITERATIONS.key,
maxIterationsEnough.toString)
Review comment:
Could you use `withSQLConf` instead?
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
##########
@@ -926,4 +926,43 @@ 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
+ val conf = new SQLConf().copy(SQLConf.ANALYZER_MAX_ITERATIONS ->
maxIterations)
+ 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."))
+
+ conf.setConfString(SQLConf.ANALYZER_MAX_ITERATIONS.key,
maxIterationsEnough.toString)
+ try {
+ testAnalyzer.execute(plan)
+ } catch {
+ case ex: TreeNodeException[_]
+ if ex.getMessage.contains(SQLConf.ANALYZER_MAX_ITERATIONS.key) =>
+ fail("analyzer.execute should not reach max iterations.")
+ }
+
+ conf.setConfString(SQLConf.ANALYZER_MAX_ITERATIONS.key,
maxIterations.toString)
Review comment:
ditto
----------------------------------------------------------------
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]