Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/22226#discussion_r214572178
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonGenerator.scala
---
@@ -43,20 +42,22 @@ private[sql] class JacksonGenerator(
// we can directly access data in `ArrayData` without the help of
`SpecificMutableRow`.
private type ValueWriter = (SpecializedGetters, Int) => Unit
- // `JackGenerator` can only be initialized with a `StructType` or a
`MapType`.
- require(dataType.isInstanceOf[StructType] ||
dataType.isInstanceOf[MapType],
- s"JacksonGenerator only supports to be initialized with a
${StructType.simpleString} " +
- s"or ${MapType.simpleString} but got ${dataType.catalogString}")
+ // `JackGenerator` can only be initialized with a `StructType`, a
`MapType` or a `ArrayType`.
+ require(dataType.isInstanceOf[StructType] ||
dataType.isInstanceOf[MapType]
+ || dataType.isInstanceOf[ArrayType],
+ s"JacksonGenerator only supports to be initialized with a
${StructType.simpleString}, " +
+ s"${MapType.simpleString} or ${ArrayType.simpleString} but got
${dataType.catalogString}")
// `ValueWriter`s for all fields of the schema
private lazy val rootFieldWriters: Array[ValueWriter] = dataType match {
case st: StructType => st.map(_.dataType).map(makeWriter).toArray
case _ => throw new UnsupportedOperationException(
- s"Initial type ${dataType.catalogString} must be a struct")
+ s"Initial type ${dataType.catalogString} must be a
${StructType.simpleString}")
}
// `ValueWriter` for array data storing rows of the schema.
private lazy val arrElementWriter: ValueWriter = dataType match {
+ case at: ArrayType => makeWriter(at.elementType)
case st: StructType =>
--- End diff --
Can we do `case _: StructType | _: MapType => makeWriter(dataType)`?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]