Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/11410#discussion_r54535121
--- 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 tried to add such a test, but couldn't figure it out. The outer scope is
the line wrapper class that generated by scala REPL framework and I'm not sure
how to insert side effect into it.
---
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]