Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Jul 13, 2016

What changes were proposed in this pull request?

SQLTestUtils.withTempDatabase is a frequently used test harness to setup a temporary table and clean up finally. This issue improves like the following for usability.

-    try f(dbName) finally spark.sql(s"DROP DATABASE $dbName CASCADE")
+    try f(dbName) finally {
+      if (spark.catalog.currentDatabase == dbName) {
+        spark.sql(s"USE ${DEFAULT_DATABASE}")
+      }
+      spark.sql(s"DROP DATABASE $dbName CASCADE")
+    }

In case of forgetting to reset the databaes, withTempDatabase will not raise Exception.

How was this patch tested?

This improves test harness.

@SparkQA
Copy link

SparkQA commented Jul 13, 2016

Test build #62268 has finished for PR 14184 at commit e1fa637.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 13, 2016

Test build #62272 has finished for PR 14184 at commit 12e8c94.

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

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Jul 14, 2016

Hi, @liancheng .
Could you review this PR?

It was made by you at 72981bc#diff-e59968489e4f36f43010dd7acd60341dR106 and used in many cases. Recently, SPARK-16459 starts to prevent dropping current database, so we had better update this.

@liancheng
Copy link
Contributor

LGTM, merging to master and branch-2.0. Thanks!

asfgit pushed a commit that referenced this pull request Jul 14, 2016
…base before dropping

## What changes were proposed in this pull request?

`SQLTestUtils.withTempDatabase` is a frequently used test harness to setup a temporary table and clean up finally. This issue improves like the following for usability.

```scala
-    try f(dbName) finally spark.sql(s"DROP DATABASE $dbName CASCADE")
+    try f(dbName) finally {
+      if (spark.catalog.currentDatabase == dbName) {
+        spark.sql(s"USE ${DEFAULT_DATABASE}")
+      }
+      spark.sql(s"DROP DATABASE $dbName CASCADE")
+    }
```

In case of forgetting to reset the databaes, `withTempDatabase` will not raise Exception.

## How was this patch tested?

This improves test harness.

Author: Dongjoon Hyun <[email protected]>

Closes #14184 from dongjoon-hyun/SPARK-16529.

(cherry picked from commit c576f9f)
Signed-off-by: Cheng Lian <[email protected]>
@dongjoon-hyun
Copy link
Member Author

Oh, thank you, @liancheng !

@asfgit asfgit closed this in c576f9f Jul 14, 2016
@dongjoon-hyun dongjoon-hyun deleted the SPARK-16529 branch July 20, 2016 07:45
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.

3 participants