wangyum commented on a change in pull request #25690:
[SPARK-27831][FOLLOW-UP][SQL][TEST][test-maven] Move Hive test jars to local
file
URL: https://github.com/apache/spark/pull/25690#discussion_r322198677
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/test/TestHive.scala
##########
@@ -647,3 +648,18 @@ private[sql] class TestHiveSessionStateBuilder(
override protected def newBuilder: NewBuilder = new
TestHiveSessionStateBuilder(_, _)
}
+
+private[hive] object HiveTestJars {
+ def getHiveContribJar: File = getJarFile("org.apache.hive:hive-contrib")
+ def getHiveHcatalogCoreJar: File =
getJarFile("org.apache.hive.hcatalog:hive-hcatalog-core")
+
+ private def getJarFile(coordinate: String): File = {
+ // isTransitive = false: Only direct dependencies should be resolved
+ val filePath = SparkSubmitUtils.resolveMavenCoordinates(
+ s"$coordinate:${HiveUtils.builtinHiveVersion}",
+ SparkSubmitUtils.buildIvySettings(
+ Some("https://repository.apache.org/content/repositories/releases"),
None),
+ isTransitive = false)
+ new File(filePath)
+ }
Review comment:
Do you prefer this?
```scala
private val repository =
"https://repository.apache.org/content/repositories/releases/"
private val hiveContribUrl = s"${repository}org/apache/hive/hive-contrib/"
+
s"${HiveUtils.builtinHiveVersion}/"
private val hiveHcatalogCoreUrl =
s"${repository}org/apache/hive/hcatalog/hive-hcatalog-core/" +
s"${HiveUtils.builtinHiveVersion}/"
def getHiveContribJar: File = getFileFromUrl(hiveContribUrl,
s"hive-contrib-${HiveUtils.builtinHiveVersion}.jar")
def getHiveHcatalogCoreJar: File = getFileFromUrl(hiveHcatalogCoreUrl,
s"hive-hcatalog-core-${HiveUtils.builtinHiveVersion}.jar")
private def getFileFromUrl(urlString: String, filename: String): File = {
val hiveTestJars = new File("/tmp/test-spark/hiveTestJars")
if (!hiveTestJars.exists()) {
hiveTestJars.mkdirs()
}
val targetFile = new File(hiveTestJars, filename)
if (!targetFile.exists() || !(targetFile.length() > 0)) {
val conf = new SparkConf
val securityManager = new org.apache.spark.SecurityManager(conf)
val hadoopConf = new Configuration
// propagate exceptions up to the caller of getFileFromUrl
Utils.doFetchFile(urlString, hiveTestJars, filename, conf,
securityManager, hadoopConf)
}
targetFile
}
```
----------------------------------------------------------------
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]