spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject spark git commit: [SPARK-15745][SQL] Use classloader's getResource() for reading resource files in HiveTests
Date Fri, 03 Jun 2016 07:13:48 GMT
Repository: spark
Updated Branches:
  refs/heads/master 76aa45d35 -> f7288e166


[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.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/f7288e16
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/f7288e16
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/f7288e16

Branch: refs/heads/master
Commit: f7288e166c696da15e790c28fc3ed78531fd362d
Parents: 76aa45d
Author: Sameer Agarwal <sameer@databricks.com>
Authored: Fri Jun 3 00:13:43 2016 -0700
Committer: Reynold Xin <rxin@databricks.com>
Committed: Fri Jun 3 00:13:43 2016 -0700

----------------------------------------------------------------------
 .../org/apache/spark/sql/hive/test/TestHive.scala      | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/f7288e16/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
----------------------------------------------------------------------
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 81964db..1d1d5e3 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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message