Skip to content

Commit

Permalink
workaround for classloader of IsolatedClientLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
chenghao-intel committed May 26, 2015
1 parent 4f4ba8f commit dd78775
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,19 @@ class CliSuite extends FunSuite with BeforeAndAfter with Logging {
-> "hive_test"
)
}

test("Single command with --jars") {
val jarFile =
Thread.currentThread().getContextClassLoader.getResource("data/files/hive-hcatalog-core-0.13.1.jar")
runCliWithin(1.minute,
Seq(
"--jars",
s"$jarFile",
"-e",
"""CREATE TABLE t1(a string, b string) ROW FORMAT
| SERDE 'org.apache.hive.hcatalog.data.JsonSerDe';""".stripMargin))(
""
-> "OK"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class HadoopTableReader(
makeRDDForTable(
hiveTable,
Class.forName(
relation.tableDesc.getSerdeClassName, true, Utils.getSparkClassLoader)
relation.tableDesc.getSerdeClassName, true, Utils.getContextOrSparkClassLoader)
.asInstanceOf[Class[Deserializer]],
filterOpt = None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ private[hive] class IsolatedClientLoader(
name.startsWith("com.google") ||
name.startsWith("java.lang.") ||
name.startsWith("java.net") ||
name.startsWith("org.apache.hadoop.conf") ||
name.startsWith("org.apache.hadoop.hive.serde") || // TODO keep adding?
sharedPrefixes.exists(name.startsWith)

/** True if `name` refers to a spark class that must see specific version of Hive. */
Expand All @@ -150,7 +152,9 @@ private[hive] class IsolatedClientLoader(
defineClass(name, bytes, 0, bytes.length)
} else if (!isSharedClass(name)) {
logDebug(s"hive class: $name - ${getResource(classToPath(name))}")
super.loadClass(name, resolve)
try super.loadClass(name, resolve) catch {
case _: ClassNotFoundException => baseClassLoader.loadClass(name)
}
} else {
logDebug(s"shared class: $name")
baseClassLoader.loadClass(name)
Expand Down

0 comments on commit dd78775

Please sign in to comment.