Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18875#discussion_r137986124
  
    --- 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 --
    
    Yeah, as you support arbitrary map. Not all map types actually, it leaves 
to `JacksonUtils` to verify the schema.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to