Skip to content
Snippets Groups Projects
Commit f7288e16 authored by Sameer Agarwal's avatar Sameer Agarwal Committed by Reynold Xin
Browse files

[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 <sameer@databricks.com>

Closes #13489 from sameeragarwal/resourcepath.
parent 76aa45d3
No related branches found
No related tags found
No related merge requests found
...@@ -179,19 +179,8 @@ private[hive] class TestHiveSparkSession( ...@@ -179,19 +179,8 @@ private[hive] class TestHiveSparkSession(
hiveFilesTemp.mkdir() hiveFilesTemp.mkdir()
ShutdownHookManager.registerShutdownDeleteDir(hiveFilesTemp) ShutdownHookManager.registerShutdownDeleteDir(hiveFilesTemp)
val inRepoTests = if (System.getProperty("user.dir").endsWith("sql" + File.separator + "hive")) {
new File("src" + File.separator + "test" + File.separator + "resources" + File.separator)
} else {
new File("sql" + File.separator + "hive" + File.separator + "src" + File.separator + "test" +
File.separator + "resources")
}
def getHiveFile(path: String): File = { def getHiveFile(path: String): File = {
val stripped = path.replaceAll("""\.\.\/""", "").replace('/', File.separatorChar) new File(Thread.currentThread().getContextClassLoader.getResource(path).getFile)
hiveDevHome
.map(new File(_, stripped))
.filter(_.exists)
.getOrElse(new File(inRepoTests, stripped))
} }
val describedTable = "DESCRIBE (\\w+)".r val describedTable = "DESCRIBE (\\w+)".r
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment