Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Sep 25, 2018

What changes were proposed in this pull request?

Currently, Spark has 7 withTempPath and 6 withSQLConf functions. This PR aims to remove duplicated and inconsistent code and reduce them to the following meaningful implementations.

withTempPath

  • SQLHelper.withTempPath: The one which was used in SQLTestUtils.

withSQLConf

  • SQLHelper.withSQLConf: The one which was used in PlanTest.
  • ExecutorSideSQLConfSuite.withSQLConf: The one which doesn't throw AnalysisException on StaticConf changes.
  • SQLTestUtils.withSQLConf: The one which overrides intentionally to change the active session.
  protected override def withSQLConf(pairs: (String, String)*)(f: => Unit): Unit = {
    SparkSession.setActiveSession(spark)
    super.withSQLConf(pairs: _*)(f)
  }

How was this patch tested?

Pass the Jenkins with the existing tests.

@dongjoon-hyun
Copy link
Member Author

Could you review this PR, @cloud-fan , @gatorsmile , and @wangyum ?

* mandating a FunSuite.
*/
trait PlanTestBase extends PredicateHelper { self: Suite =>
trait PlanTestBase extends PredicateHelper with SupportWithSQLConf { self: Suite =>
Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Sep 25, 2018

Choose a reason for hiding this comment

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

I put SupportWithSQLConf.scala in the same package with PlanTest. If needed, we can move this to another better place.

@cloud-fan
Copy link
Contributor

We have duplicated withTempPath, withTempTable too. Shall we pull them out as well? The trait name can be SQLHelper

@dongjoon-hyun
Copy link
Member Author

+1, Sure, @cloud-fan !

@dongjoon-hyun
Copy link
Member Author

It turns out that withTempTable cannot be here together because it requires spark.catalog.

  def withTempTable(tableNames: String*)(f: => Unit): Unit = {
    try f finally tableNames.foreach(spark.catalog.dropTempView)
  }

Since it requires function signature changes, shall we postpone withTempTable as another PR?

@cloud-fan
Copy link
Contributor

sure

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-25534][SQL] Make SupportWithSQLConf trait [SPARK-25534][SQL] Make SQLHelper trait Sep 26, 2018
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

LGTM if the tests pass

@SparkQA
Copy link

SparkQA commented Sep 26, 2018

Test build #96579 has finished for PR 22548 at commit bc4d71d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait PlanTestBase extends PredicateHelper with SupportWithSQLConf
  • trait SupportWithSQLConf

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Sep 26, 2018

Thank you, @HyukjinKwon and @cloud-fan ! I'll merge this to the master. It's still running.

@SparkQA
Copy link

SparkQA commented Sep 26, 2018

Test build #96586 has finished for PR 22548 at commit 0827ede.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait PlanTestBase extends PredicateHelper with SQLHelper
  • trait SQLHelper
  • abstract class CheckpointFileManagerTests extends SparkFunSuite with SQLHelper

@dongjoon-hyun
Copy link
Member Author

It passed. Merged to master.

@asfgit asfgit closed this in 81cbcca Sep 26, 2018
@dongjoon-hyun dongjoon-hyun deleted the SPARK-25534 branch September 26, 2018 06:22
daspalrahul pushed a commit to daspalrahul/spark that referenced this pull request Sep 29, 2018
## What changes were proposed in this pull request?

Currently, Spark has 7 `withTempPath` and 6 `withSQLConf` functions. This PR aims to remove duplicated and inconsistent code and reduce them to the following meaningful implementations.

**withTempPath**
- `SQLHelper.withTempPath`: The one which was used in `SQLTestUtils`.

**withSQLConf**
- `SQLHelper.withSQLConf`: The one which was used in `PlanTest`.
- `ExecutorSideSQLConfSuite.withSQLConf`: The one which doesn't throw `AnalysisException` on StaticConf changes.
- `SQLTestUtils.withSQLConf`: The one which overrides intentionally to change the active session.
```scala
  protected override def withSQLConf(pairs: (String, String)*)(f: => Unit): Unit = {
    SparkSession.setActiveSession(spark)
    super.withSQLConf(pairs: _*)(f)
  }
```

## How was this patch tested?

Pass the Jenkins with the existing tests.

Closes apache#22548 from dongjoon-hyun/SPARK-25534.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants