Skip to content
Closed
Prev Previous commit
fix test failed
  • Loading branch information
windpiger committed Mar 6, 2017
commit 5b423f56b69a11b44cbc8ce6bf1e8821619ebf79
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach {
sql(s"DESCRIBE DATABASE EXTENDED $dbName"),
Row("Database Name", dbNameWithoutBackTicks) ::
Row("Description", "") ::
Row("Location", location) ::
Row("Location", CatalogUtils.URIToString(location)) ::
Row("Properties", "") :: Nil)

sql(s"ALTER DATABASE $dbName SET DBPROPERTIES ('a'='a', 'b'='b', 'c'='c')")
Expand All @@ -457,7 +457,7 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach {
sql(s"DESCRIBE DATABASE EXTENDED $dbName"),
Row("Database Name", dbNameWithoutBackTicks) ::
Row("Description", "") ::
Row("Location", location) ::
Row("Location", CatalogUtils.URIToString(location)) ::
Row("Properties", "((a,a), (b,b), (c,c))") :: Nil)

sql(s"ALTER DATABASE $dbName SET DBPROPERTIES ('d'='d')")
Expand All @@ -466,7 +466,7 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach {
sql(s"DESCRIBE DATABASE EXTENDED $dbName"),
Row("Database Name", dbNameWithoutBackTicks) ::
Row("Description", "") ::
Row("Location", location) ::
Row("Location", CatalogUtils.URIToString(location)) ::
Row("Properties", "((a,a), (b,b), (c,c), (d,d))") :: Nil)
} finally {
catalog.reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1690,11 +1690,11 @@ class HiveDDLSuite
}
}

Seq("a b", "a:b", "a%b").foreach { specialCharInLoc =>
test(s"location uri contains $specialCharInLoc for datasource table") {
Seq("a b", "a:b", "a%b").foreach { specialChars =>
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a TODO to remove these duplicated tests when we merge DDLSuite and HiveDDLSuite

Copy link
Member

Choose a reason for hiding this comment

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

This introduces the conflict in my PR #16592. Let me remove the duplicate there.

test(s"datasource table: location uri contains $specialChars") {
withTable("t", "t1") {
withTempDir { dir =>
val loc = new File(dir, specialCharInLoc)
val loc = new File(dir, specialChars)
loc.mkdir()
spark.sql(
s"""
Expand All @@ -1705,7 +1705,7 @@ class HiveDDLSuite

val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
assert(table.location == new Path(loc.getAbsolutePath).toUri)
assert(new Path(table.location).toString.contains(specialCharInLoc))
assert(new Path(table.location).toString.contains(specialChars))

assert(loc.listFiles().isEmpty)
spark.sql("INSERT INTO TABLE t SELECT 1")
Expand All @@ -1714,7 +1714,7 @@ class HiveDDLSuite
}

withTempDir { dir =>
val loc = new File(dir, specialCharInLoc)
val loc = new File(dir, specialChars)
loc.mkdir()
spark.sql(
s"""
Expand All @@ -1726,7 +1726,7 @@ class HiveDDLSuite

val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t1"))
assert(table.location == new Path(loc.getAbsolutePath).toUri)
assert(new Path(table.location).toString.contains(specialCharInLoc))
assert(new Path(table.location).toString.contains(specialChars))

assert(loc.listFiles().isEmpty)
spark.sql("INSERT INTO TABLE t1 PARTITION(b=2) SELECT 1")
Expand All @@ -1746,7 +1746,7 @@ class HiveDDLSuite
}

Seq("a b", "a:b", "a%b").foreach { specialChars =>
test(s"location uri contains $specialChars for hive table") {
test(s"hive table: location uri contains $specialChars") {
withTable("t") {
withTempDir { dir =>
val loc = new File(dir, specialChars)
Expand All @@ -1762,10 +1762,10 @@ class HiveDDLSuite
val path = new Path(loc.getAbsolutePath)
val fs = path.getFileSystem(spark.sessionState.newHadoopConf())
assert(table.location == fs.makeQualified(path).toUri)
assert(new Path(table.location).toString.contains(specialCharInLoc))
assert(new Path(table.location).toString.contains(specialChars))

assert(loc.listFiles().isEmpty)
if (specialCharInLoc != "a:b") {
if (specialChars != "a:b") {
spark.sql("INSERT INTO TABLE t SELECT 1")
assert(loc.listFiles().length >= 1)
checkAnswer(spark.table("t"), Row("1") :: Nil)
Expand All @@ -1792,10 +1792,10 @@ class HiveDDLSuite
val path = new Path(loc.getAbsolutePath)
val fs = path.getFileSystem(spark.sessionState.newHadoopConf())
assert(table.location == fs.makeQualified(path).toUri)
assert(new Path(table.location).toString.contains(specialCharInLoc))
assert(new Path(table.location).toString.contains(specialChars))

assert(loc.listFiles().isEmpty)
if (specialCharInLoc != "a:b") {
if (specialChars != "a:b") {
spark.sql("INSERT INTO TABLE t1 PARTITION(b=2) SELECT 1")
val partFile = new File(loc, "b=2")
assert(partFile.listFiles().length >= 1)
Expand Down