Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-26681][SQL] Support Ammonite inner-class scopes. #23607

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -53,6 +53,12 @@ object OuterScopes {
val outer = outerScopes.get(outerClassName)
if (outer == null) {
outerClassName match {
case AmmoniteREPLClass(cellClassName) =>
() => {
val objClass = Utils.classForName(cellClassName)
val objInstance = objClass.getField("MODULE$").get(null)
objClass.getMethod("instance").invoke(objInstance)
}
// If the outer class is generated by REPL, users don't need to register it as it has
// only one instance and there is a way to retrieve it: get the `$read` object, call the
// `INSTANCE()` method to get the single instance of class `$read`. Then call `$iw()`
Expand Down Expand Up @@ -95,4 +101,8 @@ object OuterScopes {

// The format of REPL generated wrapper class's name, e.g. `$line12.$read$$iw$$iw`
private[this] val REPLClass = """^(\$line(?:\d+)\.\$read)(?:\$\$iw)+$""".r

// The format of ammonite REPL generated wrapper class's name,
// e.g. `ammonite.$sess.cmd8$Helper$Foo` -> `ammonite.$sess.cmd8.instance.Foo`
private[this] val AmmoniteREPLClass = """^(ammonite\.\$sess\.cmd(?:\d+)\$).*""".r
}