Skip to content
Snippets Groups Projects
Commit b66aa900 authored by Dongjoon Hyun's avatar Dongjoon Hyun Committed by Sean Owen
Browse files

[SPARK-14102][CORE] Block `reset` command in SparkShell

## What changes were proposed in this pull request?

Spark Shell provides an easy way to use Spark in Scala environment. This PR adds `reset` command to a blocked list, also cleaned up according to the Scala coding style.
```scala
scala> sc
res0: org.apache.spark.SparkContext = org.apache.spark.SparkContext718fad24
scala> :reset
scala> sc
<console>:11: error: not found: value sc
       sc
       ^
```
If we blocks `reset`, Spark Shell works like the followings.
```scala
scala> :reset
reset: no such command.  Type :help for help.
scala> :re
re is ambiguous: did you mean :replay or :require?
```

## How was this patch tested?

Manual. Run `bin/spark-shell` and type `:reset`.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #11920 from dongjoon-hyun/SPARK-14102.
parent 7b841540
Branches main
No related tags found
No related merge requests found
...@@ -19,12 +19,11 @@ package org.apache.spark.repl ...@@ -19,12 +19,11 @@ package org.apache.spark.repl
import java.io.BufferedReader import java.io.BufferedReader
import Predef.{println => _, _} import scala.Predef.{println => _, _}
import scala.util.Properties.{javaVersion, versionString, javaVmName}
import scala.tools.nsc.interpreter.{JPrintWriter, ILoop}
import scala.tools.nsc.Settings import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.{ILoop, JPrintWriter}
import scala.tools.nsc.util.stringFromStream import scala.tools.nsc.util.stringFromStream
import scala.util.Properties.{javaVersion, javaVmName, versionString}
/** /**
* A Spark-specific interactive shell. * A Spark-specific interactive shell.
...@@ -75,11 +74,9 @@ class SparkILoop(in0: Option[BufferedReader], out: JPrintWriter) ...@@ -75,11 +74,9 @@ class SparkILoop(in0: Option[BufferedReader], out: JPrintWriter)
echo("Type :help for more information.") echo("Type :help for more information.")
} }
import LoopCommand.{ cmd, nullary } private val blockedCommands = Set("implicits", "javap", "power", "type", "kind", "reset")
private val blockedCommands = Set("implicits", "javap", "power", "type", "kind")
/** Standard commands **/ /** Standard commands */
lazy val sparkStandardCommands: List[SparkILoop.this.LoopCommand] = lazy val sparkStandardCommands: List[SparkILoop.this.LoopCommand] =
standardCommands.filter(cmd => !blockedCommands(cmd.name)) standardCommands.filter(cmd => !blockedCommands(cmd.name))
...@@ -112,9 +109,9 @@ object SparkILoop { ...@@ -112,9 +109,9 @@ object SparkILoop {
val output = new JPrintWriter(new OutputStreamWriter(ostream), true) val output = new JPrintWriter(new OutputStreamWriter(ostream), true)
val repl = new SparkILoop(input, output) val repl = new SparkILoop(input, output)
if (sets.classpath.isDefault) if (sets.classpath.isDefault) {
sets.classpath.value = sys.props("java.class.path") sets.classpath.value = sys.props("java.class.path")
}
repl process sets repl process sets
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment