Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/9726#discussion_r45426470
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/encoders/ExpressionEncoder.scala
---
@@ -44,20 +44,21 @@ import org.apache.spark.sql.types.{NullType,
StructField, ObjectType, StructType
* to the name `value`.
*/
object ExpressionEncoder {
- def apply[T : TypeTag](flat: Boolean = false): ExpressionEncoder[T] = {
+ def apply[T : TypeTag](): ExpressionEncoder[T] = {
// We convert the not-serializable TypeTag into StructType and
ClassTag.
val mirror = typeTag[T].mirror
val cls = mirror.runtimeClass(typeTag[T].tpe)
+ val flat = !classOf[Product].isAssignableFrom(cls)
--- End diff --
But we need a way to detect flatness automatically, sometimes we only have
the type `T` and nothing else, like when we wanna use encoders for `ScalaUDF`.
How about `flat = !ScalaReflection.schemaFor[T].isInstanceOf[StructType])`?
---
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]