Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/9810#discussion_r45392361
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala
---
@@ -607,6 +607,89 @@ object ScalaReflection extends ScalaReflection {
}
}
}
+
+ /**
+ * Validates a type for encoder recursively. If it's not supported,
i.e. there is no encoder can
+ * be built for this type, an [[UnsupportedOperationException]] will be
thrown with detailed
+ * error message to explain the type path walked so far and which class
we are not supporting.
+ * There are 4 kinds of type path:
+ * * the root type: `root class: "abc.xyz.MyClass"`
+ * * the value type of [[Option]]: `option value class:
"abc.xyz.MyClass"`
+ * * the element type of [[Array]] or [[Seq]]: `array element class:
"abc.xyz.MyClass"`
+ * * the field of [[Product]]: `field (class: "abc.xyz.MyClass", name:
"myField")`
+ */
+ def validateTypeForEncoder(tpe: `Type`): Unit = {
+ val clsName = getClassNameFromType(tpe)
+ validateTypeForEncoder(tpe, s"""- root class: "${clsName}"""" :: Nil)
+ }
+
+ private def validateTypeForEncoder(tpe: `Type`, walkedTypePath:
Seq[String]): Unit =
--- End diff --
Why is this a separate function now? Now we have duplicated copies of the
same logic that can fall out of sync.
---
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]