aboutsummaryrefslogtreecommitdiff
path: root/sql/hive/src
diff options
context:
space:
mode:
authorSameer Agarwal <sameer@databricks.com>2016-06-03 00:13:43 -0700
committerReynold Xin <rxin@databricks.com>2016-06-03 00:13:43 -0700
commitf7288e166c696da15e790c28fc3ed78531fd362d (patch)
treeb8b5c86634b994dd230ea7a2fb917eb5750e51aa /sql/hive/src
parent76aa45d359d034e9ccaac64b36738d47e1e42f2c (diff)
downloadspark-f7288e166c696da15e790c28fc3ed78531fd362d.tar.gz
spark-f7288e166c696da15e790c28fc3ed78531fd362d.tar.bz2
spark-f7288e166c696da15e790c28fc3ed78531fd362d.zip
[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.
Diffstat (limited to 'sql/hive/src')
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala13
1 files changed, 1 insertions, 12 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
index 81964db547..1d1d5e3f7b 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
@@ -179,19 +179,8 @@ private[hive] class TestHiveSparkSession(
hiveFilesTemp.mkdir()
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 = {
- val stripped = path.replaceAll("""\.\.\/""", "").replace('/', File.separatorChar)
- hiveDevHome
- .map(new File(_, stripped))
- .filter(_.exists)
- .getOrElse(new File(inRepoTests, stripped))
+ new File(Thread.currentThread().getContextClassLoader.getResource(path).getFile)
}
val describedTable = "DESCRIBE (\\w+)".r