Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/1598#discussion_r15620793
--- Diff: python/pyspark/sql.py ---
@@ -951,16 +938,39 @@ def count(self):
"""
return self._jschema_rdd.count()
- def _toPython(self):
- # We have to import the Row class explicitly, so that the
reference Pickler has is
- # pyspark.sql.Row instead of __main__.Row
- from pyspark.sql import Row
- jrdd = self._jschema_rdd.javaToPython()
- # TODO: This is inefficient, we should construct the Python Row
object
- # in Java land in the javaToPython function. May require a custom
- # pickle serializer in Pyrolite
- return RDD(jrdd, self._sc, BatchedSerializer(
- PickleSerializer())).map(lambda d: Row(d))
+ def collect(self):
+ """
+ Return a list that contains all of the rows in this RDD.
+
+ Each object in the list is on Row, the fields can be accessed as
+ attributes.
+ """
+ rows = RDD.collect(self)
+ cls = _create_cls(self.schema())
+ return map(cls, rows)
+
+ # convert Row in JavaSchemaRDD into namedtuple, let access fields
easier
--- End diff --
thx
---
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.
---