Skip to content

Commit

Permalink
[SPARK-16656][SQL][BRANCH-1.6] Try to make CreateTableAsSelectSuite m…
Browse files Browse the repository at this point in the history
…ore stable

## What changes were proposed in this pull request?

This PR backports apache#14289 to branch 1.6

https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62593/testReport/junit/org.apache.spark.sql.sources/CreateTableAsSelectSuite/create_a_table__drop_it_and_create_another_one_with_the_same_name/ shows that `create a table, drop it and create another one with the same name` failed. But other runs were good. Seems it is a flaky test. This PR tries to make this test more stable.

Author: Yin Huai <[email protected]>

Closes apache#14668 from yhuai/SPARK-16656-branch1.6.
  • Loading branch information
yhuai committed Aug 16, 2016
1 parent 4d64c7f commit 5c34029
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,45 @@ package org.apache.spark.sql.sources

import java.io.{File, IOException}

import org.scalatest.BeforeAndAfter
import org.scalatest.BeforeAndAfterEach

import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.execution.datasources.DDLException
import org.apache.spark.sql.test.SharedSQLContext
import org.apache.spark.util.Utils

class CreateTableAsSelectSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter {
class CreateTableAsSelectSuite
extends DataSourceTest
with SharedSQLContext
with BeforeAndAfterEach {

protected override lazy val sql = caseInsensitiveContext.sql _
private var path: File = null

override def beforeAll(): Unit = {
super.beforeAll()
path = Utils.createTempDir()
val rdd = sparkContext.parallelize((1 to 10).map(i => s"""{"a":$i, "b":"str${i}"}"""))
caseInsensitiveContext.read.json(rdd).registerTempTable("jt")
}

override def afterAll(): Unit = {
try {
caseInsensitiveContext.dropTempTable("jt")
Utils.deleteRecursively(path)
} finally {
super.afterAll()
}
}

after {
override def beforeEach(): Unit = {
super.beforeEach()
path = Utils.createTempDir()
path.delete()
}

override def afterEach(): Unit = {
Utils.deleteRecursively(path)
super.afterEach()
}

test("CREATE TEMPORARY TABLE AS SELECT") {
Expand Down

0 comments on commit 5c34029

Please sign in to comment.