1818package org .apache .spark .sql .hive .execution
1919
2020import java .io .File
21+ import java .net .URI
2122
2223import org .apache .hadoop .fs .Path
2324import 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