Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
afaf7bd
[SPARK-33084][CORE][SQL]Add jar support ivy path
AngersZhuuuu Oct 7, 2020
51daf9a
Merge branch 'master' into support-add-jar-ivy
AngersZhuuuu Oct 7, 2020
3579de0
Update SparkContextSuite.scala
AngersZhuuuu Oct 7, 2020
d6e8caf
Merge branch 'support-add-jar-ivy' of https://github.com/AngersZhuuuu…
AngersZhuuuu Oct 7, 2020
169e1f8
Update Utils.scala
AngersZhuuuu Oct 8, 2020
0e589ec
Merge branch 'master' into support-add-jar-ivy
AngersZhuuuu Nov 21, 2020
b3e3211
resolve conflict
AngersZhuuuu Nov 23, 2020
9161340
Update SessionState.scala
AngersZhuuuu Nov 23, 2020
0e3c1ec
Update sql-ref-syntax-aux-resource-mgmt-add-jar.md
AngersZhuuuu Nov 24, 2020
300ca56
follow comment
AngersZhuuuu Nov 24, 2020
63e877b
https://github.com/apache/spark/pull/29966#discussion_r529242208
AngersZhuuuu Nov 24, 2020
733e62c
follow comment
AngersZhuuuu Nov 24, 2020
b60ba1e
Update sql-ref-syntax-aux-resource-mgmt-add-jar.md
AngersZhuuuu Nov 24, 2020
883b9d3
fix uri re-use
AngersZhuuuu Nov 28, 2020
208afc2
follow comment
AngersZhuuuu Nov 28, 2020
ba9ea29
add warn message whe multiple trasitive
AngersZhuuuu Nov 28, 2020
10b3737
move DependencyUtils
AngersZhuuuu Nov 28, 2020
7f878c2
add ut
AngersZhuuuu Nov 28, 2020
d2c1950
Update SessionState.scala
AngersZhuuuu Nov 28, 2020
2200076
Update SessionState.scala
AngersZhuuuu Nov 28, 2020
5a9cc30
Update DependencyUtils.scala
AngersZhuuuu Nov 29, 2020
875d8a7
Add end to end test
AngersZhuuuu Nov 29, 2020
e921245
Update SQLQuerySuite.scala
AngersZhuuuu Nov 29, 2020
614a865
follow comment
AngersZhuuuu Nov 30, 2020
8c5cb7c
Update SparkContext.scala
AngersZhuuuu Nov 30, 2020
f460974
fix local path with comma
AngersZhuuuu Nov 30, 2020
1f7dc01
Merge branch 'support-add-jar-ivy' of https://github.com/AngersZhuuuu…
AngersZhuuuu Dec 1, 2020
050c410
follow comment
AngersZhuuuu Dec 1, 2020
ff611a6
Update SessionState.scala
AngersZhuuuu Dec 1, 2020
03aca3b
split UT and use simply dependency ivy path
AngersZhuuuu Dec 1, 2020
653b919
Update DependencyUtils.scala
AngersZhuuuu Dec 1, 2020
6e48275
Update SparkContext.scala
AngersZhuuuu Dec 1, 2020
bdc5035
follow comment
AngersZhuuuu Dec 2, 2020
9c22882
follow comment
AngersZhuuuu Dec 2, 2020
9c88f8d
follow comment
AngersZhuuuu Dec 2, 2020
8220e5a
Update SparkContextSuite.scala
AngersZhuuuu Dec 2, 2020
49ac62c
follow comment
AngersZhuuuu Dec 2, 2020
b69a62e
Update DependencyUtils.scala
AngersZhuuuu Dec 2, 2020
273a5ac
Follow comment
AngersZhuuuu Dec 3, 2020
ebe1c9c
Update DependencyUtils.scala
AngersZhuuuu Dec 4, 2020
6034fb2
Update sql-ref-syntax-aux-resource-mgmt-add-jar.md
AngersZhuuuu Dec 5, 2020
e22e398
Update SparkContext.scala
AngersZhuuuu Dec 7, 2020
afea73f
Update SparkContext.scala
AngersZhuuuu Dec 7, 2020
13000f2
Merge branch 'master' into support-add-jar-ivy
AngersZhuuuu Dec 14, 2020
bce3d40
Update SparkContext.scala
AngersZhuuuu Dec 14, 2020
d53f302
Merge branch 'support-add-jar-ivy' of https://github.com/AngersZhuuuu…
AngersZhuuuu Dec 14, 2020
57c351d
Update HiveQuerySuite.scala
AngersZhuuuu Dec 15, 2020
8c53b83
follow comment
AngersZhuuuu Dec 22, 2020
4048c5b
https://github.com/apache/spark/pull/29966#discussion_r547040115
AngersZhuuuu Dec 22, 2020
aa53482
Merge branch 'master' into support-add-jar-ivy
AngersZhuuuu Dec 22, 2020
2ffb431
Update SQLQuerySuite.scala
AngersZhuuuu Dec 22, 2020
8c18cdf
Update SparkContext.scala
AngersZhuuuu Dec 23, 2020
6bd41cd
Update SparkSubmit.scala
AngersZhuuuu Dec 23, 2020
fbc236c
follwo comment
AngersZhuuuu Dec 23, 2020
90491d5
Update DependencyUtils.scala
AngersZhuuuu Dec 23, 2020
75ff3ce
Update SparkContextSuite.scala
AngersZhuuuu Dec 23, 2020
4c44dae
follow comment remove default value
AngersZhuuuu Dec 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
follow comment
  • Loading branch information
AngersZhuuuu committed Dec 22, 2020
commit 8c53b83d1650a69b4225cdbca4fd26d1d5537d94
6 changes: 3 additions & 3 deletions core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2003,14 +2003,14 @@ class SparkContext(config: SparkConf) extends Logging {
val timestamp = if (addedOnSubmit) startTime else System.currentTimeMillis
val (added, existed) = keys.partition(addedJars.putIfAbsent(_, timestamp).isEmpty)
if (added.nonEmpty) {
val jarMessage = if (schema != "ivy") "JAR" else "dependency jars of ivy uri"
val jarMessage = if (schema != "ivy") "JAR" else "dependency jars of Ivy URI"
logInfo(s"Added $jarMessage $path at ${added.mkString(",")} with timestamp $timestamp")
postEnvironmentUpdate()
}
if (existed.nonEmpty) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add tests to check if this warning message is shown only once by using LogAppender?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add tests to check if this warning message is shown only once by using LogAppender?

Sure

val jarMessage = if (schema != "ivy") "JAR" else "dependency jars of ivy uri"
val jarMessage = if (schema != "ivy") "JAR" else "dependency jars of Ivy URI"
logInfo(s"The $jarMessage $path at ${existed.mkString(",")} has been added already." +
s" Overwriting of added jar is not supported in the current version.")
" Overwriting of added jar is not supported in the current version.")
}
}
}
Expand Down
38 changes: 19 additions & 19 deletions core/src/main/scala/org/apache/spark/util/DependencyUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ private[spark] object DependencyUtils extends Logging {
* Parse URI query string's parameter value of `transitive` and `exclude`.
* Other invalid parameters will be ignored.
*
* @param uri Ivy uri need to be downloaded.
* @param uri Ivy URI need to be downloaded.
* @return Tuple value of parameter `transitive` and `exclude` value.
*
* 1. transitive: whether to download dependency jar of ivy URI, default value is false
* 1. transitive: whether to download dependency jar of Ivy URI, default value is false
* and this parameter value is case-sensitive. Invalid value will be treat as false.
* Example: Input: exclude=org.mortbay.jetty:jetty&transitive=true
* Output: true
Expand All @@ -77,56 +77,56 @@ private[spark] object DependencyUtils extends Logging {
val mapTokens = uriQuery.split("&").map(_.split("="))
if (mapTokens.exists(isInvalidQueryString)) {
throw new IllegalArgumentException(
s"Invalid query string in ivy uri ${uri.toString}: $uriQuery")
s"Invalid query string in Ivy URI ${uri.toString}: $uriQuery")
}
val groupedParams = mapTokens.map(kv => (kv(0), kv(1))).groupBy(_._1)

// Parse transitive parameters (e.g., transitive=true) in an ivy URL, default value is false
// Parse transitive parameters (e.g., transitive=true) in an Ivy URI, default value is false
val transitiveParams = groupedParams.get("transitive")
if (transitiveParams.map(_.size).getOrElse(0) > 1) {
logWarning("It's best to specify `transitive` parameter in ivy URL query only once." +
logWarning("It's best to specify `transitive` parameter in ivy URI query only once." +
" If there are multiple `transitive` parameter, we will select the last one")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hive has the same behaviour with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hive has the same behaviour with this?

No, but we can have this warning

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, what's the hive behaviour? it will throw an exception instead selecting the last one?

Copy link
Contributor Author

@AngersZhuuuu AngersZhuuuu Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, what's the hive behaviour? it will throw an exception instead selecting the last one?

Select the last one
https://github.com/apache/hive/blob/aed7c86cdd59f0b2a4979633fbd191d451f2fd75/ql/src/java/org/apache/hadoop/hive/ql/util/DependencyResolver.java#L121-L127

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok.

}
val transitive =
transitiveParams.flatMap(_.takeRight(1).map(_._2 == "true").headOption).getOrElse(false)

// Parse an excluded list (e.g., exclude=org.mortbay.jetty:jetty,org.eclipse.jetty:jetty-http)
// in an ivy URL. When download ivy URL jar, Spark won't download transitive jar
// in an Ivy URI. When download Ivy URI jar, Spark won't download transitive jar
// in a excluded list.
val exclusionList = groupedParams.get("exclude").map { params =>
params.map(_._2).flatMap { excludeString =>
val excludes = excludeString.split(",")
if (excludes.map(_.split(":")).exists(isInvalidQueryString)) {
throw new IllegalArgumentException(
s"Invalid exclude string in ivy uri ${uri.toString}:" +
s" expected 'org:module,org:module,..', found " + excludeString)
s"Invalid exclude string in Ivy URI ${uri.toString}:" +
" expected 'org:module,org:module,..', found " + excludeString)
}
excludes
}.mkString(",")
}.getOrElse("")

val validParams = Set("transitive", "exclude")
val invalidParams = groupedParams.keys.filterNot(validParams.contains).toSeq.sorted
val invalidParams = groupedParams.keys.filterNot(validParams.contains).toSeq
if (invalidParams.nonEmpty) {
logWarning(s"Invalid parameters `${invalidParams.mkString(",")}` found " +
s"in ivy uri query `$uriQuery`.")
logWarning(s"Invalid parameters `${invalidParams.sorted.mkString(",")}` found " +
s"in Ivy URI query `$uriQuery`.")
}

(transitive, exclusionList)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if an invalid param is given in hive, e.g., invalidParam=xxxx? It is just ignored? Could you add tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should at least warn on invalid param?

}
}

/**
* Download Ivy URIs dependency jars.
* Download Ivy URI's dependency jars.
*
* @param uri Ivy uri need to be downloaded. The URI format should be:
* @param uri Ivy URI need to be downloaded. The URI format should be:
* `ivy://group:module:version[?query]`
* Ivy URI query part format should be:
* `parameter=value&parameter=value...`
* Note that currently ivy URI query part support two parameters:
* 1. transitive: whether to download dependent jars related to your ivy URL.
* Note that currently Ivy URI query part support two parameters:
* 1. transitive: whether to download dependent jars related to your Ivy URI.
* transitive=false or `transitive=true`, if not set, the default value is false.
* 2. exclude: exclusion list when download ivy URL jar and dependency jars.
* 2. exclude: exclusion list when download Ivy URI jar and dependency jars.
* The `exclude` parameter content is a ',' separated `group:module` pair string :
* `exclude=group:module,group:module...`
* @return Comma separated string list of jars downloaded.
Expand All @@ -136,12 +136,12 @@ private[spark] object DependencyUtils extends Logging {
val authority = uri.getAuthority
if (authority == null) {
throw new IllegalArgumentException(
s"Invalid ivy url authority in uri ${uri.toString}:" +
s" Expected 'org:module:version', found null.")
s"Invalid Ivy URI authority in uri ${uri.toString}:" +
" Expected 'org:module:version', found null.")
}
if (authority.split(":").length != 3) {
throw new IllegalArgumentException(
s"Invalid ivy uri authority in uri ${uri.toString}:" +
s"Invalid Ivy URI authority in uri ${uri.toString}:" +
s" Expected 'org:module:version', found $authority.")
}

Expand Down
36 changes: 18 additions & 18 deletions core/src/test/scala/org/apache/spark/SparkContextSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
}
}

test("SPARK-33084: Add jar support ivy url -- default transitive = false") {
test("SPARK-33084: Add jar support Ivy URI -- default transitive = false") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0")
assert(sc.listJars().exists(_.contains("org.apache.hive_hive-storage-api-2.7.0.jar")))
Expand All @@ -1068,15 +1068,15 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
assert(sc.listJars().exists(_.contains("commons-lang_commons-lang-2.6.jar")))
}

test("SPARK-33084: Add jar support ivy url -- invalid transitive use default false") {
test("SPARK-33084: Add jar support Ivy URI -- invalid transitive use default false") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0?transitive=foo")
assert(sc.listJars().exists(_.contains("org.apache.hive_hive-storage-api-2.7.0.jar")))
assert(!sc.listJars().exists(_.contains("org.slf4j_slf4j-api-1.7.10.jar")))
assert(!sc.listJars().exists(_.contains("commons-lang_commons-lang-2.6.jar")))
}

test("SPARK-33084: Add jar support ivy url -- transitive=true will download dependency jars") {
test("SPARK-33084: Add jar support Ivy URI -- transitive=true will download dependency jars") {
val logAppender = new LogAppender("transitive=true will download dependency jars")
withLogAppender(logAppender) {
sc = new SparkContext(
Expand All @@ -1090,23 +1090,23 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
dependencyJars.foreach(jar => assert(sc.listJars().exists(_.contains(jar))))

assert(logAppender.loggingEvents.count(_.getRenderedMessage.contains(
"Added dependency jars of ivy uri" +
"Added dependency jars of Ivy URI" +
" ivy://org.apache.hive:hive-storage-api:2.7.0?transitive=true")) == 1)

// test dependency jars exist
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0?transitive=true")
assert(logAppender.loggingEvents.count(_.getRenderedMessage.contains(
"The dependency jars of ivy uri" +
"The dependency jars of Ivy URI" +
" ivy://org.apache.hive:hive-storage-api:2.7.0?transitive=true")) == 1)
val existMsg = logAppender.loggingEvents.filter(_.getRenderedMessage.contains(
"The dependency jars of ivy uri" +
"The dependency jars of Ivy URI" +
" ivy://org.apache.hive:hive-storage-api:2.7.0?transitive=true"))
.head.getRenderedMessage
dependencyJars.foreach(jar => assert(existMsg.contains(jar)))
}
}

test("SPARK-33084: Add jar support ivy url -- test exclude param when transitive=true") {
test("SPARK-33084: Add jar support Ivy URI -- test exclude param when transitive=true") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0" +
"?exclude=commons-lang:commons-lang&transitive=true")
Expand All @@ -1115,15 +1115,15 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
assert(!sc.listJars().exists(_.contains("commons-lang_commons-lang-2.6.jar")))
}

test("SPARK-33084: Add jar support ivy url -- test different version") {
test("SPARK-33084: Add jar support Ivy URI -- test different version") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0")
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.6.0")
assert(sc.listJars().exists(_.contains("org.apache.hive_hive-storage-api-2.7.0.jar")))
assert(sc.listJars().exists(_.contains("org.apache.hive_hive-storage-api-2.6.0.jar")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the jars first, then check if the dependent jars co-exist in sc.listJars?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, this behaviour is the same with hive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the jars first, then check if the dependent jars co-exist in sc.listJars?

Done

}

test("SPARK-33084: Add jar support ivy url -- test invalid param") {
test("SPARK-33084: Add jar support Ivy URI -- test invalid param") {
val logAppender = new LogAppender("test log when have invalid parameter")
withLogAppender(logAppender) {
sc = new SparkContext(
Expand All @@ -1132,12 +1132,12 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
"invalidParam1=foo&invalidParam2=boo")
assert(sc.listJars().exists(_.contains("org.apache.hive_hive-storage-api-2.7.0.jar")))
assert(logAppender.loggingEvents.exists(_.getRenderedMessage.contains(
"Invalid parameters `invalidParam1,invalidParam2` found in ivy uri query" +
"Invalid parameters `invalidParam1,invalidParam2` found in Ivy URI query" +
" `invalidParam1=foo&invalidParam2=boo`.")))
}
}

test("SPARK-33084: Add jar support ivy url -- test multiple transitive params") {
test("SPARK-33084: Add jar support Ivy URI -- test multiple transitive params") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
// transitive=invalidValue will win and treated as false
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0?" +
Expand All @@ -1152,7 +1152,7 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
assert(sc.listJars().exists(_.contains("commons-lang_commons-lang-2.6.jar")))
}

test("SPARK-33084: Add jar support ivy url -- test param case sensitive") {
test("SPARK-33084: Add jar support Ivy URI -- test param case sensitive") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0?TRANSITIVE=true")
assert(sc.listJars().exists(_.contains("org.apache.hive_hive-storage-api-2.7.0.jar")))
Expand All @@ -1163,7 +1163,7 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
assert(sc.listJars().exists(_.contains("commons-lang_commons-lang-2.6.jar")))
}

test("SPARK-33084: Add jar support ivy url -- test transitive value case sensitive") {
test("SPARK-33084: Add jar support Ivy URI -- test transitive value case sensitive") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
sc.addJar("ivy://org.apache.hive:hive-storage-api:2.7.0?transitive=TRUE")
assert(sc.listJars().exists(_.contains("org.apache.hive_hive-storage-api-2.7.0.jar")))
Expand All @@ -1174,7 +1174,7 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
assert(sc.listJars().exists(_.contains("commons-lang_commons-lang-2.6.jar")))
}

test("SPARK-33084: Add jar support ivy url -- test invalid ivy uri") {
test("SPARK-33084: Add jar support Ivy URI -- test invalid ivy uri") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local-cluster[3, 1, 1024]"))
val e1 = intercept[IllegalArgumentException] {
sc.addJar("ivy://")
Expand All @@ -1184,25 +1184,25 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
val e2 = intercept[IllegalArgumentException] {
sc.addJar("ivy://org.apache.hive:hive-contrib")
}.getMessage
assert(e2.contains("Invalid ivy uri authority in uri ivy://org.apache.hive:hive-contrib:" +
assert(e2.contains("Invalid Ivy URI authority in uri ivy://org.apache.hive:hive-contrib:" +
" Expected 'org:module:version', found org.apache.hive:hive-contrib."))

val e3 = intercept[IllegalArgumentException] {
sc.addJar("ivy://org.apache.hive:hive-contrib:2.3.7?foo=")
}.getMessage
assert(e3.contains("Invalid query string in ivy uri" +
assert(e3.contains("Invalid query string in Ivy URI" +
" ivy://org.apache.hive:hive-contrib:2.3.7?foo=:"))

val e4 = intercept[IllegalArgumentException] {
sc.addJar("ivy://org.apache.hive:hive-contrib:2.3.7?bar=&baz=foo")
}.getMessage
assert(e4.contains("Invalid query string in ivy uri" +
assert(e4.contains("Invalid query string in Ivy URI" +
" ivy://org.apache.hive:hive-contrib:2.3.7?bar=&baz=foo: bar=&baz=foo"))

val e5 = intercept[IllegalArgumentException] {
sc.addJar("ivy://org.apache.hive:hive-contrib:2.3.7?exclude=org.pentaho")
}.getMessage
assert(e5.contains("Invalid exclude string in ivy uri" +
assert(e5.contains("Invalid exclude string in Ivy URI" +
" ivy://org.apache.hive:hive-contrib:2.3.7?exclude=org.pentaho:" +
" expected 'org:module,org:module,..', found org.pentaho"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3719,7 +3719,7 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
}
}

test("SPARK-33084: Add jar support ivy url in SQL") {
test("SPARK-33084: Add jar support Ivy URI in SQL") {
val sc = spark.sparkContext
// default transitive=false, only download specified jar
sql("ADD JAR ivy://org.apache.hive.hcatalog:hive-hcatalog-core:2.3.7")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1220,20 +1220,21 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
}
}

test("SPARK-33084: Add jar support ivy url in SQL") {
test("SPARK-33084: Add jar support Ivy URI in SQL") {
val testData = TestHive.getHiveFile("data/files/sample.json").toURI
sql("ADD JAR ivy://org.apache.hive.hcatalog:hive-hcatalog-core:2.3.7")
sql(
"""CREATE TABLE t1(a string, b string)
|ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'""".stripMargin)
sql(s"""LOAD DATA LOCAL INPATH "$testData" INTO TABLE t1""")
sql("select * from src join t1 on src.key = t1.a")
sql("DROP TABLE t1")
assert(sql("list jars").filter(_.getString(0).contains(
"org.apache.hive.hcatalog_hive-hcatalog-core-2.3.7.jar")).count() > 0)
assert(sql("list jar").
filter(_.getString(0).contains(
withTable("t") {
sql("ADD JAR ivy://org.apache.hive.hcatalog:hive-hcatalog-core:2.3.7")
sql(
"""CREATE TABLE t(a string, b string)
|ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'""".stripMargin)
sql(s"""LOAD DATA LOCAL INPATH "$testData" INTO TABLE t""")
sql("SELECT * FROM src JOIN t on src.key = t.a")
assert(sql("LIST JARS").filter(_.getString(0).contains(
"org.apache.hive.hcatalog_hive-hcatalog-core-2.3.7.jar")).count() > 0)
assert(sql("LIST JAR").
filter(_.getString(0).contains(
"org.apache.hive.hcatalog_hive-hcatalog-core-2.3.7.jar")).count() > 0)
}
}
}

Expand Down