You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/09/25 23:40:38 UTC
[GitHub] [spark] marmbrus commented on a change in pull request #29403: [SPARK-32585][SQL] Support scala enumeration in ScalaReflection
marmbrus commented on a change in pull request #29403:
URL: https://github.com/apache/spark/pull/29403#discussion_r495318035
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala
##########
@@ -739,6 +771,8 @@ object ScalaReflection extends ScalaReflection {
val Schema(dataType, nullable) = schemaFor(fieldType)
StructField(fieldName, dataType, nullable)
}), nullable = true)
+ case t if isSubtype(t, localTypeOf[Enumeration#Value]) =>
+ Schema(StringType, nullable = false)
Review comment:
Why is `nullable = false`, I believe this should be reserved for primitive types that *cannot* be null.
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
##########
@@ -1926,6 +1926,13 @@ class DatasetSuite extends QueryTest
}
}
}
+
+ test("SPARK-32585: Support scala enumeration in ScalaReflection") {
+ checkDataset(
+ Seq(FooClassWithEnum(1, FooEnum.E1), FooClassWithEnum(2, FooEnum.E2)).toDS(),
+ Seq(FooClassWithEnum(1, FooEnum.E1), FooClassWithEnum(2, FooEnum.E2)): _*
Review comment:
Related to the above comment, I would add a test case where the enum value is `null`.
##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/ScalaReflectionSuite.scala
##########
@@ -437,4 +445,11 @@ class ScalaReflectionSuite extends SparkFunSuite {
StructField("f2", StringType))))
assert(deserializerFor[FooWithAnnotation].dataType == ObjectType(classOf[FooWithAnnotation]))
}
+
+ test("SPARK-32585: Support scala enumeration in ScalaReflection") {
Review comment:
I would consider putting a test case in `ExpressionEncoderSuite` as well as I think that checks various combinations of evaluation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org