Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11410#discussion_r54452439
  
    --- Diff: 
repl/scala-2.11/src/test/scala/org/apache/spark/repl/ReplSuite.scala ---
    @@ -254,6 +254,30 @@ class ReplSuite extends SparkFunSuite {
             |import sqlContext.implicits._
             |case class TestCaseClass(value: Int)
             |sc.parallelize(1 to 10).map(x => 
TestCaseClass(x)).toDF().collect()
    +        |
    +        |// Test Dataset Serialization in the REPL
    +        |Seq(TestCaseClass(1)).toDS().collect()
    +      """.stripMargin)
    +    assertDoesNotContain("error:", output)
    +    assertDoesNotContain("Exception", output)
    +  }
    +
    +  test("Datasets and encoders") {
    +    val output = runInterpreter("local",
    +      """
    +        |import org.apache.spark.sql.functions._
    +        |import org.apache.spark.sql.Encoder
    +        |import org.apache.spark.sql.expressions.Aggregator
    +        |import org.apache.spark.sql.TypedColumn
    +        |val simpleSum = new Aggregator[Int, Int, Int] {
    +        |  def zero: Int = 0                     // The initial value.
    +        |  def reduce(b: Int, a: Int) = b + a    // Add an element to the 
running total
    +        |  def merge(b1: Int, b2: Int) = b1 + b2 // Merge intermediate 
values.
    +        |  def finish(b: Int) = b                // Return the final 
result.
    +        |}.toColumn
    +        |
    +        |val ds = Seq(1, 2, 3, 4).toDS()
    +        |ds.select(simpleSum).collect
    --- End diff --
    
    I think your solution works, but it might be good to add a test case where 
the scope that gets captured has a side effect (i.e. create a file so if you 
double execute the outer scope it will fail the second time).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to