Github user goldmedal commented on a diff in the pull request:
https://github.com/apache/spark/pull/18875#discussion_r137984767
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala
---
@@ -677,14 +696,42 @@ case class StructsToJson(
override def checkInputDataTypes(): TypeCheckResult = child.dataType
match {
case _: StructType | ArrayType(_: StructType, _) =>
try {
- JacksonUtils.verifySchema(rowSchema)
+ JacksonUtils.verifySchema(rowSchema.asInstanceOf[StructType])
+ TypeCheckResult.TypeCheckSuccess
+ } catch {
+ case e: UnsupportedOperationException =>
+ TypeCheckResult.TypeCheckFailure(e.getMessage)
+ }
+ case ArrayType(mt: MapType, _) =>
+ try {
+ val st = StructType(StructField("a", mt) :: Nil)
+ JacksonUtils.verifySchema(st)
+ TypeCheckResult.TypeCheckSuccess
+ } catch {
+ case e: UnsupportedOperationException =>
+ TypeCheckResult.TypeCheckFailure(e.getMessage)
+ }
+ case MapType(_: DataType, st: StructType, _: Boolean) =>
--- End diff --
@viirya I think if we have `case mt: MapType`, we don't need this pattern
to verify schema, right?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]