[SPARK-1897] Respect spark.jars (and --jars) in spark-shell

Spark shell currently overwrites `spark.jars` with `ADD_JARS`. In all modes except yarn-cluster, this means the `--jar` flag passed to `bin/spark-shell` is also discarded. However, in the [docs](http://people.apache.org/~pwendell/spark-1.0.0-rc7-docs/scala-programming-guide.html#initializing-spark), we explicitly tell the users to add the jars this way.

Author: Andrew Or <andrewor14@gmail.com>

Closes #849 from andrewor14/shell-jars and squashes the following commits:

928a7e6 [Andrew Or] ',' -> "," (minor)
afc357c [Andrew Or] Handle spark.jars == "" in SparkILoop, not SparkSubmit
c6da113 [Andrew Or] Do not set spark.jars to ""
d8549f7 [Andrew Or] Respect spark.jars and --jars in spark-shell
This commit is contained in:
Andrew Or 2014-05-22 20:25:41 -07:00 committed by Tathagata Das
parent f9f5fd5f4e
commit 8edbee7d1b

View file

@ -993,7 +993,13 @@ object SparkILoop {
implicit def loopToInterpreter(repl: SparkILoop): SparkIMain = repl.intp
private def echo(msg: String) = Console println msg
def getAddedJars: Array[String] = Option(System.getenv("ADD_JARS")).map(_.split(',')).getOrElse(new Array[String](0))
def getAddedJars: Array[String] = {
val envJars = sys.env.get("ADD_JARS")
val propJars = sys.props.get("spark.jars").flatMap { p =>
if (p == "") None else Some(p)
}
propJars.orElse(envJars).map(_.split(",")).getOrElse(Array.empty)
}
// Designed primarily for use by test code: take a String with a
// bunch of code, and prints out a transcript of what it would look