Github user MaxGekk commented on a diff in the pull request:
https://github.com/apache/spark/pull/22226#discussion_r214878373
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala
---
@@ -663,12 +662,7 @@ case class StructsToJson(
rowSchema, writer, new JSONOptions(options, timeZoneId.get))
@transient
- lazy val rowSchema = child.dataType match {
- case st: StructType => st
- case ArrayType(st: StructType, _) => st
- case mt: MapType => mt
- case ArrayType(mt: MapType, _) => mt
- }
+ lazy val rowSchema = child.dataType
--- End diff --
I tried to remove `lazy` and got many errors on tests like:
```
Invalid call to dataType on unresolved object, tree: 'a
org.apache.spark.sql.catalyst.analysis.UnresolvedException: Invalid call to
dataType on unresolved object, tree: 'a
at
org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute.dataType(unresolved.scala:105)
at
org.apache.spark.sql.catalyst.expressions.StructsToJson.<init>(jsonExpressions.scala:665)
```
If you don't mind, I will keep it `lazy`.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]