Skip to content

Commit f7288e1

Browse files
sameeragarwalrxin
authored andcommitted
[SPARK-15745][SQL] Use classloader's getResource() for reading resource files in HiveTests
## What changes were proposed in this pull request? This is a cleaner approach in general but my motivation behind this change in particular is to be able to run these tests from anywhere without relying on system properties. ## How was this patch tested? Test only change Author: Sameer Agarwal <[email protected]> Closes #13489 from sameeragarwal/resourcepath.
1 parent 76aa45d commit f7288e1

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,8 @@ private[hive] class TestHiveSparkSession(
179179
hiveFilesTemp.mkdir()
180180
ShutdownHookManager.registerShutdownDeleteDir(hiveFilesTemp)
181181

182-
val inRepoTests = if (System.getProperty("user.dir").endsWith("sql" + File.separator + "hive")) {
183-
new File("src" + File.separator + "test" + File.separator + "resources" + File.separator)
184-
} else {
185-
new File("sql" + File.separator + "hive" + File.separator + "src" + File.separator + "test" +
186-
File.separator + "resources")
187-
}
188-
189182
def getHiveFile(path: String): File = {
190-
val stripped = path.replaceAll("""\.\.\/""", "").replace('/', File.separatorChar)
191-
hiveDevHome
192-
.map(new File(_, stripped))
193-
.filter(_.exists)
194-
.getOrElse(new File(inRepoTests, stripped))
183+
new File(Thread.currentThread().getContextClassLoader.getResource(path).getFile)
195184
}
196185

197186
val describedTable = "DESCRIBE (\\w+)".r

0 commit comments

Comments
 (0)