Skip to content

Commit 4efb630

Browse files
cxzl25dongjoon-hyun
authored andcommitted
[SPARK-52587][SHELL] spark-shell 2.13 support -i -I parameter
### What changes were proposed in this pull request? ### Why are the changes needed? In spark-shell 2.12 we supported the `-i` and `-I` parameters, but in version 2.13, we did not support it. https://github.com/apache/spark/blob/185380c414d2e9822b90a9c0a9e83052a4aa83c1/repl/src/main/scala-2.12/org/apache/spark/repl/SparkILoop.scala#L170-L180 --- If we correctly construct ShellConfig, we can reuse scala's processing `-i` and `-I` logic. scala.tools.nsc.interpreter.shell.ILoop#interpretPreamble ```scala for (f <- filesToLoad) { loadCommand(f) addReplay(s":load $f") } for (f <- filesToPaste) { pasteCommand(f) addReplay(s":paste $f") } ``` ### Does this PR introduce _any_ user-facing change? Yes ### How was this patch tested? local test ### Was this patch authored or co-authored using generative AI tooling? No Closes #51294 from cxzl25/SPARK-52587. Authored-by: sychen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 063144d commit 4efb630

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

repl/src/main/scala/org/apache/spark/repl/Main.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ object Main extends Logging {
5757

5858
def main(args: Array[String]): Unit = {
5959
isShellSession = true
60-
doMain(args, new SparkILoop)
60+
val settings = new GenericRunnerSettings(scalaOptionError)
61+
settings.processArguments(args.toList, true)
62+
doMain(args, new SparkILoop(settings))
6163
}
6264

6365
// Visible for testing

repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ import scala.util.Properties.{javaVersion, javaVmName, versionString}
3131
/**
3232
* A Spark-specific interactive shell.
3333
*/
34-
class SparkILoop(in0: BufferedReader, out: PrintWriter)
35-
extends ILoop(ShellConfig(new GenericRunnerSettings(_ => ())), in0, out) {
36-
def this() = this(null, new PrintWriter(Console.out, true))
34+
class SparkILoop(config: ShellConfig, in0: BufferedReader, out: PrintWriter)
35+
extends ILoop(config, in0, out) {
36+
def this(in0: BufferedReader, out: PrintWriter) = this(
37+
ShellConfig(new GenericRunnerSettings(_ => ())), in0, out)
38+
39+
def this(settings: Settings) = this(ShellConfig(settings), null,
40+
new PrintWriter(Console.out, true))
41+
42+
def this() = this(new GenericRunnerSettings(_ => ()))
3743

3844
val initializationCommands: Seq[String] = Seq(
3945
"""

0 commit comments

Comments
 (0)