Skip to content

Commit 3dcd6c6

Browse files
committed
modify some tests
1 parent f4b4d29 commit 3dcd6c6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.spark.sql.hive.execution
1919

2020
import java.io.File
21+
import java.net.URI
2122

2223
import org.apache.hadoop.fs.Path
2324
import org.scalatest.BeforeAndAfterEach
@@ -1603,7 +1604,7 @@ class HiveDDLSuite
16031604
val fs = dirPath.getFileSystem(spark.sessionState.newHadoopConf())
16041605
assert(new Path(table.location) == fs.makeQualified(dirPath))
16051606

1606-
val tableLocFile = new File(table.location.stripPrefix("file:"))
1607+
val tableLocFile = new File(new URI(table.location))
16071608
tableLocFile.delete()
16081609
assert(!tableLocFile.exists())
16091610
spark.sql("INSERT INTO TABLE t SELECT 'c', 1")
@@ -1617,12 +1618,12 @@ class HiveDDLSuite
16171618
checkAnswer(spark.table("t"), Row("c", 1) :: Nil)
16181619

16191620
val newDirFile = new File(dir, "x")
1620-
val newDirPath = newDirFile.getAbsolutePath.stripSuffix("/")
1621+
val newDirPath = newDirFile.getAbsolutePath
16211622
spark.sql(s"ALTER TABLE t SET LOCATION '$newDirPath'")
16221623
spark.sessionState.catalog.refreshTable(TableIdentifier("t"))
16231624

16241625
val table1 = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
1625-
assert(table1.location.stripSuffix("/") == newDirPath)
1626+
assert(table1.location == newDirPath)
16261627
assert(!newDirFile.exists())
16271628

16281629
spark.sql("INSERT INTO TABLE t SELECT 'c', 1")
@@ -1659,7 +1660,7 @@ class HiveDDLSuite
16591660
checkAnswer(spark.table("t"), Row(7, 8, 1, 2) :: Nil)
16601661

16611662
val newDirFile = new File(dir, "x")
1662-
val newDirPath = newDirFile.getAbsolutePath.stripSuffix("/")
1663+
val newDirPath = newDirFile.getAbsolutePath
16631664
spark.sql(s"ALTER TABLE t PARTITION(a=1, b=2) SET LOCATION '$newDirPath'")
16641665
assert(!newDirFile.exists())
16651666

@@ -1689,11 +1690,11 @@ class HiveDDLSuite
16891690
checkAnswer(spark.table("t"), Nil)
16901691

16911692
val newDirFile = new File(dir, "x")
1692-
val newDirPath = newDirFile.getAbsolutePath.stripSuffix("/")
1693+
val newDirPath = newDirFile.getAbsolutePath
16931694
spark.sql(s"ALTER TABLE t SET LOCATION '$newDirPath'")
16941695

16951696
val table1 = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
1696-
assert(table1.location.stripSuffix("/") == newDirPath)
1697+
assert(table1.location == newDirPath)
16971698
assert(!newDirFile.exists())
16981699
checkAnswer(spark.table("t"), Nil)
16991700
}

0 commit comments

Comments
 (0)