wangyum commented on a change in pull request #25690: 
[SPARK-27831][FOLLOW-UP][SQL][TEST][test-hadoop3.2] Move Hive test jars to 
local file
URL: https://github.com/apache/spark/pull/25690#discussion_r324423064
 
 

 ##########
 File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/test/TestHive.scala
 ##########
 @@ -647,3 +647,29 @@ private[sql] class TestHiveSessionStateBuilder(
 
   override protected def newBuilder: NewBuilder = new 
TestHiveSessionStateBuilder(_, _)
 }
+
+private[hive] object HiveTestJars {
+  private val repository = 
"https://repository.apache.org/content/repositories/releases/";
+
+  def getHiveContribJar: File =
+    getJarFromUrl(s"${repository}org/apache/hive/hive-contrib/" +
+      
s"${HiveUtils.builtinHiveVersion}/hive-contrib-${HiveUtils.builtinHiveVersion}.jar")
+  def getHiveHcatalogCoreJar: File =
+    getJarFromUrl(s"${repository}org/apache/hive/hcatalog/hive-hcatalog-core/" 
+
+      
s"${HiveUtils.builtinHiveVersion}/hive-hcatalog-core-${HiveUtils.builtinHiveVersion}.jar")
+
+  private def getJarFromUrl(urlString: String): File = {
+    val fileName = urlString.split("/").last
+    val hiveTestJarsDir = new File("/tmp/test-spark/hiveTestJars")
+    if (!hiveTestJarsDir.exists()) {
+      hiveTestJarsDir.mkdirs()
+    }
+    val targetFile = new File(hiveTestJarsDir, fileName)
+    if (!targetFile.exists() || !(targetFile.length() > 0)) {
 
 Review comment:
   `!(targetFile.length() > 0)` avoids file corruption, because all tests use 
this file, we don't need it after changing the temporary directory to 
`Utils.createTempDir()`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to