Skip to content

[SPARK-33042][SQL][TEST] Add a test case to ensure changes to spark.sql.optimizer.maxIterations take effect at runtime#29919

Closed
yuningzh-db wants to merge 3 commits intoapache:masterfrom
yuningzh-db:add_optimizer_test
Closed

[SPARK-33042][SQL][TEST] Add a test case to ensure changes to spark.sql.optimizer.maxIterations take effect at runtime#29919
yuningzh-db wants to merge 3 commits intoapache:masterfrom
yuningzh-db:add_optimizer_test

Conversation

@yuningzh-db
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add a test case to ensure changes to spark.sql.optimizer.maxIterations take effect at runtime.

Why are the changes needed?

Currently, there is only one related test case: https://github.com/apache/spark/blob/master/sql/core/src/test/scala/org/apache/spark/sql/internal/SQLConfSuite.scala#L156

However, this test case only checks the value of the conf can be changed at runtime. It does not check the updated value is actually used by the Optimizer.

Does this PR introduce any user-facing change?

No

How was this patch tested?

unit test

@rednaxelafx
Copy link
Copy Markdown
Contributor

(Not a Reviewer) LGTM. Thanks for making this behavior explicitly verified with a test case!

@yuningzh-db yuningzh-db changed the title [SPARK-33042] Add a test case to ensure changes to spark.sql.optimizer.maxIterations take effect at runtime [SPARK-33042][SQL] Add a test case to ensure changes to spark.sql.optimizer.maxIterations take effect at runtime Oct 1, 2020
@maropu
Copy link
Copy Markdown
Member

maropu commented Oct 1, 2020

ok to test

@maropu maropu changed the title [SPARK-33042][SQL] Add a test case to ensure changes to spark.sql.optimizer.maxIterations take effect at runtime [SPARK-33042][SQL][TEST] Add a test case to ensure changes to spark.sql.optimizer.maxIterations take effect at runtime Oct 1, 2020
val maxIterationsEnough = 10
val analyzed = Project(Alias(Literal(iterations), "attr")() :: Nil, OneRowRelation()).analyze

conf.setConf(SQLConf.OPTIMIZER_MAX_ITERATIONS, maxIterationsNotEnough)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use withSQLConf instead?

}
}

class OptimizerMaxIterationsSuite extends PlanTest {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, since AnalysisSuite has tests for ANALYZER_MAX_ITERATIONS, how about making the name more general, e.g., OptimizerSuite?

val analyzed = Project(Alias(Literal(iterations), "attr")() :: Nil, OneRowRelation()).analyze

conf.setConf(SQLConf.OPTIMIZER_MAX_ITERATIONS, maxIterationsNotEnough)
val optimizer = new SimpleTestOptimizer() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using SparkOptimizer instead of using SimpleTestOptimizer? That's because the existing test for ANALYZER_MAX_ITERATIONS uses Analyzer directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems all other Optimizer-related tests are using SimpleTestOptimizer. I guess it is the proper one to be used based on the context.

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 1, 2020

Test build #129293 has finished for PR 29919 at commit 9627aec.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class OptimizerMaxIterationsSuite extends PlanTest

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 1, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33909/

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 1, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33909/

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 1, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33913/

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 1, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33913/

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 1, 2020

Test build #129297 has finished for PR 29919 at commit 61f8baa.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class OptimizerSuite extends PlanTest

}

class OptimizerSuite extends PlanTest {
test("Adjust maxIterations") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about Optimizer exceeds max iterations instead?

/**
* A dummy optimizer rule for testing that decrements integer literals until 0.
*/
object DecrementLiterals extends Rule[LogicalPlan] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this dummy rule for this test? Could we just use object SimpleTestOptimizer instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test needs to control the number of iterations needed for the plan. With the default batch and rules, it is not clear how many iterations will be needed and we should not fix that value.

@maropu
Copy link
Copy Markdown
Member

maropu commented Oct 1, 2020

Looks ok otherwise.

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 2, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33970/

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 2, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33970/

@SparkQA
Copy link
Copy Markdown

SparkQA commented Oct 2, 2020

Test build #129360 has finished for PR 29919 at commit 188d667.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Copy Markdown
Member

Merged to master.

@yuningzh-db yuningzh-db deleted the add_optimizer_test branch October 5, 2020 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants