Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/15354#discussion_r82443073
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/JsonExpressionsSuite.scala
---
@@ -343,4 +343,23 @@ class JsonExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
null
)
}
+
+ test("to_json") {
+ val schema = StructType(StructField("a", IntegerType) :: Nil)
+ val struct = Literal.create(create_row(1), schema)
+ checkEvaluation(
+ StructToJson(Map.empty, struct),
+ """{"a":1}"""
+ )
+ }
+
+ test("to_json - invalid type") {
+ val schema = StructType(StructField("a", CalendarIntervalType) :: Nil)
--- End diff --
Hmm, I realize this is a little different than `from_json`, but it seems it
would be better to eagerly throw an `AnalysisException` to say the schema
contains an unsupported type. We know that ahead of time, and otherwise its
kind of mysterious why all the values come out as `null`.
---
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]