File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
sql/hive/src/main/scala/org/apache/spark/sql/hive/client Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ package org.apache.spark.sql.hive.client
19
19
20
20
import java .io .{File , PrintStream }
21
21
import java .util .{Map => JMap }
22
- import javax .annotation .concurrent .GuardedBy
23
22
24
23
import scala .collection .JavaConverters ._
25
24
import scala .language .reflectiveCalls
@@ -548,7 +547,15 @@ private[hive] class ClientWrapper(
548
547
}
549
548
550
549
def addJar (path : String ): Unit = {
551
- clientLoader.addJar(path)
550
+ val uri = new Path (path).toUri
551
+ val jarURL = if (uri.getScheme == null ) {
552
+ // `path` is a local file path without a URL scheme
553
+ new File (path).toURI.toURL
554
+ } else {
555
+ // `path` is a URL with a scheme
556
+ uri.toURL
557
+ }
558
+ clientLoader.addJar(jarURL)
552
559
runSqlHive(s " ADD JAR $path" )
553
560
}
554
561
Original file line number Diff line number Diff line change @@ -22,18 +22,16 @@ import java.lang.reflect.InvocationTargetException
22
22
import java .net .{URL , URLClassLoader }
23
23
import java .util
24
24
25
- import scala .collection .mutable
26
25
import scala .language .reflectiveCalls
27
26
import scala .util .Try
28
27
29
28
import org .apache .commons .io .{FileUtils , IOUtils }
30
29
31
30
import org .apache .spark .Logging
32
31
import org .apache .spark .deploy .SparkSubmitUtils
33
- import org .apache .spark .util .{MutableURLClassLoader , Utils }
34
-
35
32
import org .apache .spark .sql .catalyst .util .quietly
36
33
import org .apache .spark .sql .hive .HiveContext
34
+ import org .apache .spark .util .{MutableURLClassLoader , Utils }
37
35
38
36
/** Factory for `IsolatedClientLoader` with specific versions of hive. */
39
37
private [hive] object IsolatedClientLoader {
@@ -190,9 +188,8 @@ private[hive] class IsolatedClientLoader(
190
188
new NonClosableMutableURLClassLoader (isolatedClassLoader)
191
189
}
192
190
193
- private [hive] def addJar (path : String ): Unit = synchronized {
194
- val jarURL = new java.io.File (path).toURI.toURL
195
- classLoader.addURL(jarURL)
191
+ private [hive] def addJar (path : URL ): Unit = synchronized {
192
+ classLoader.addURL(path)
196
193
}
197
194
198
195
/** The isolated client interface to Hive. */
You can’t perform that action at this time.
0 commit comments