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-13456][SQL][follow-up] lazily generate the outer pointer for case class defined in REPL #11931
Conversation
Haven't tried it, but for the test, does it work by simply passing a multi-line string starting with line |
Test build #54021 has finished for PR 11931 at commit
|
@liancheng another problem is: how to simulate CTRL+D with string? We need to exit paste mode finally. |
Did some experiment locally, we can use |
test("define case class and create Dataset together") { | ||
val output = runInterpreter("local-cluster[1,1,1024]", | ||
""" | ||
|case class A(value: Int); sqlContext.createDataset(Seq(A(1)))(newProductEncoder[A]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use Seq(A(1)).toDS()
here, but it exposes another bug of our spark shell: we can't find implicit for DatasetHolder
. Will file a JIRA later.
@cloud-fan ASCII code of test("foo") {
val output = runInterpreter("local",
""":paste
|val a = 1
|println(a)
""".stripMargin + 4.toChar.toString
)
println(
s"""###################
|$output
|###################
""".stripMargin)
} |
It works! Many thanks to @liancheng ! |
@@ -59,6 +59,10 @@ class ReplSuite extends SparkFunSuite { | |||
return out.toString | |||
} | |||
|
|||
// Simulate the paste mode in Scala REPL. | |||
def runInterpreterInPasteMode(master: String, input: String): String = | |||
runInterpreter(master, ":paste\n" + input + 4.toChar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment to explain that 4.toChar
is CTRL-D
.
Test build #54036 has finished for PR 11931 at commit
|
LGTM pending Jenkins. |
Test build #54039 has finished for PR 11931 at commit
|
Test build #54043 has finished for PR 11931 at commit
|
retest this please. |
Test build #54130 has finished for PR 11931 at commit
|
retest this please |
Test build #54146 has finished for PR 11931 at commit
|
Merging to master. |
What changes were proposed in this pull request?
In #11410, we missed a corner case: define the inner class and use it in
Dataset
at the same time by using paste mode. For this case, the inner class and theDataset
are inside same line object, when we build theDataset
, we try to get outer pointer from line object, and it will fail because the line object is not initialized yet.https://issues.apache.org/jira/browse/SPARK-13456?focusedCommentId=15209174&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15209174 is an example for this corner case.
This PR make the process of getting outer pointer from line object lazy, so that we can successfully build the
Dataset
and finish initializing the line object.How was this patch tested?
new test in repl suite.