aboutsummaryrefslogtreecommitdiff
path: root/sql/core/src
diff options
context:
space:
mode:
authorCheng Lian <lian@databricks.com>2016-03-01 01:07:45 +0800
committerCheng Lian <lian@databricks.com>2016-03-01 01:07:45 +0800
commit916fc34f98dd731f607d9b3ed657bad6cc30df2c (patch)
tree414b4058495685eb8b66fa494e91ff7429ab9432 /sql/core/src
parentac5c635281aa796547e31e20c10d2483469294ee (diff)
downloadspark-916fc34f98dd731f607d9b3ed657bad6cc30df2c.tar.gz
spark-916fc34f98dd731f607d9b3ed657bad6cc30df2c.tar.bz2
spark-916fc34f98dd731f607d9b3ed657bad6cc30df2c.zip
[SPARK-13540][SQL] Supports using nested classes within Scala objects as Dataset element type
## What changes were proposed in this pull request? Nested classes defined within Scala objects are translated into Java static nested classes. Unlike inner classes, they don't need outer scopes. But the analyzer still thinks that an outer scope is required. This PR fixes this issue simply by checking whether a nested class is static before looking up its outer scope. ## How was this patch tested? A test case is added to `DatasetSuite`. It checks contents of a Dataset whose element type is a nested class declared in a Scala object. Author: Cheng Lian <lian@databricks.com> Closes #11421 from liancheng/spark-13540-object-as-outer-scope.
Diffstat (limited to 'sql/core/src')
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala10
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
index 14fc37b64a..33df6375e3 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
@@ -621,12 +621,22 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
ds.filter(_ => true),
Some(1), Some(2), Some(3))
}
+
+ test("SPARK-13540 Dataset of nested class defined in Scala object") {
+ checkAnswer(
+ Seq(OuterObject.InnerClass("foo")).toDS(),
+ OuterObject.InnerClass("foo"))
+ }
}
class OuterClass extends Serializable {
case class InnerClass(a: String)
}
+object OuterObject {
+ case class InnerClass(a: String)
+}
+
case class ClassData(a: String, b: Int)
case class ClassData2(c: String, d: Int)
case class ClassNullableData(a: String, b: Integer)