Github user HyukjinKwon commented on the pull request:
https://github.com/apache/spark/pull/13105#issuecomment-219588474
Just for a note, JSON data source is doing this in via
[`JacsonGenerator.apply()`](https://github.com/apache/spark/blob/d6dc12ef0146ae409834c78737c116050961f350/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/json/JacksonGenerator.scala#L36-L86)
which is equivalent with
[`CSVRelation.rowToString()`](https://github.com/apache/spark/blob/d6dc12ef0146ae409834c78737c116050961f350/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVRelation.scala#L159-L165).
However, it seems JSON is doing this because it needs to traverse the schema
as a tree to verify if each type is supported or not. So, it seems this is
doing this while writing each row.
For CSV, it does not need to traverse a tree but just look the root types
because it does not support nested types. So, schema can be checked faster.
Therefore, it seems reasonable to me.
---
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]