Skip to content

[SPARK-16656] [SQL] Try to make CreateTableAsSelectSuite more stable #14289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.apache.spark.sql.sources

import java.io.File

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

import org.apache.spark.SparkException
import org.apache.spark.sql.catalyst.TableIdentifier
Expand All @@ -29,33 +29,38 @@ import org.apache.spark.sql.execution.datasources.BucketSpec
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 = spark.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}"}"""))
spark.read.json(rdd).createOrReplaceTempView("jt")
}

override def afterAll(): Unit = {
try {
spark.catalog.dropTempView("jt")
if (path.exists()) {
Utils.deleteRecursively(path)
}
Utils.deleteRecursively(path)
} finally {
super.afterAll()
}
}

before {
if (path.exists()) {
Utils.deleteRecursively(path)
}
override def beforeEach(): Unit = {
super.beforeEach()
path = Utils.createTempDir()
path.delete()
}

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

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