Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhuai committed Feb 10, 2015
1 parent 98e7cdb commit 0832ce4
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ class CreateTableAsSelectSuite extends DataSourceTest with BeforeAndAfterAll {
sql("SELECT a, b FROM jsonTable"),
sql("SELECT a, b FROM jt").collect())

dropTempTable("jsonTable")

val message = intercept[RuntimeException]{
val message = intercept[DDLException]{
sql(
s"""
|CREATE TEMPORARY TABLE jsonTable
|CREATE TEMPORARY TABLE IF NOT EXISTS jsonTable
|USING org.apache.spark.sql.json.DefaultSource
|OPTIONS (
| path '${path.toString}'
Expand All @@ -91,10 +89,25 @@ class CreateTableAsSelectSuite extends DataSourceTest with BeforeAndAfterAll {
""".stripMargin)
}.getMessage
assert(
message.contains(s"path ${path.toString} already exists."),
message.contains(s"a CREATE TEMPORARY TABLE statement does not allow IF NOT EXISTS clause."),
"CREATE TEMPORARY TABLE IF NOT EXISTS should not be allowed.")

// Explicitly delete it.
// Overwrite the temporary table.
sql(
s"""
|CREATE TEMPORARY TABLE jsonTable
|USING org.apache.spark.sql.json.DefaultSource
|OPTIONS (
| path '${path.toString}'
|) AS
|SELECT a * 4 FROM jt
""".stripMargin)
checkAnswer(
sql("SELECT * FROM jsonTable"),
sql("SELECT a * 4 FROM jt").collect())

dropTempTable("jsonTable")
// Explicitly delete the data.
if (path.exists()) Utils.deleteRecursively(path)

sql(
Expand All @@ -104,12 +117,12 @@ class CreateTableAsSelectSuite extends DataSourceTest with BeforeAndAfterAll {
|OPTIONS (
| path '${path.toString}'
|) AS
|SELECT a * 4 FROM jt
|SELECT b FROM jt
""".stripMargin)

checkAnswer(
sql("SELECT * FROM jsonTable"),
sql("SELECT a * 4 FROM jt").collect())
sql("SELECT b FROM jt").collect())

dropTempTable("jsonTable")
}
Expand Down

0 comments on commit 0832ce4

Please sign in to comment.