Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/1598#discussion_r15713885
--- Diff: python/pyspark/sql.py ---
@@ -494,18 +838,18 @@ def __init__(self, sparkContext, sqlContext=None):
ValueError:...
>>> from datetime import datetime
- >>> allTypes = sc.parallelize([{"int": 1, "string": "string",
"double": 1.0, "long": 1L,
- ... "boolean": True, "time": datetime(2010, 1, 1, 1, 1, 1),
"dict": {"a": 1},
- ... "list": [1, 2, 3]}])
- >>> srdd = sqlCtx.inferSchema(allTypes).map(lambda x: (x.int,
x.string, x.double, x.long,
- ... x.boolean, x.time, x.dict["a"], x.list))
+ >>> allTypes = sc.parallelize([Row(int=1, string="string",
+ ... double=1.0, long=1L, boolean=True, list=[1, 2, 3],
+ ... time=datetime(2010, 1, 1, 1, 1, 1), dict={"a": 1})])
+ >>> srdd = sqlCtx.inferSchema(allTypes).map(lambda x: (x.int,
x.string,
+ ... x.double, x.long, x.boolean, x.time, x.dict["a"], x.list))
--- End diff --
It would be great to also add a SQL test here to make sure that types are
matching up with those expected in the execution engine. (though we might
change the names to avoid conflict with reserved words, as we have not
implemented identifier escaping). In particular the complex nested ones like
dict and list. Also it would be good to add a nested Row to the input types.
Something like:
```python
srdd.registerAsTable("pythonData")
sqlCtx.sql("SELECT dict['a'], list[0], nested.nestedField").collect() ...
```
---
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.
---