Github user davies commented on the pull request:
https://github.com/apache/spark/pull/2716#issuecomment-58577324
It will be cool to reuse the schema merging code from JsonRDD, some
concerns:
1. the schema merging logic is special designed for JSON, such as it
convert all the conflict types into StringType. This works for JSON, but not
the best solution for Python RDD.
For example, if user have two rows:
```
{a: 2}
{a: 'abc'}
```
JsonRDD will infer type the of `a` as StringType, then it will have runtime
exception when trying to access it as IntType.
SchemaRDD expects that each column should have same type, so I'd like to
raise exception during inferring, not runtime. It's better to let user deal
with the dirty datetypes before inferring schema .
2. it can not handle MapType (this can be added).
3. Most of code in JsonRDD are inferring types and converting objects into
inferred types, these two can only be done in Python. The merging part is not
so huge, also we may expect different behavior in Python (more strictly).
If user really want the behavior that JsonRDD provided, it's easy to call
```
sqlContext.jsonRDD(rdd.map(json.dumps))
```
Do these seem reasonable?
---
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]