You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/10/27 06:03:02 UTC

[GitHub] [spark] HyukjinKwon commented on a diff in pull request #38409: [SPARK-40930][CONNECT] Support Collect() in Python client

HyukjinKwon commented on code in PR #38409:
URL: https://github.com/apache/spark/pull/38409#discussion_r1006432921


##########
python/pyspark/sql/connect/dataframe.py:
##########
@@ -305,8 +308,12 @@ def _print_plan(self) -> str:
             return self._plan.print()
         return ""
 
-    def collect(self) -> None:
-        raise NotImplementedError("Please use toPandas().")
+    def collect(self) -> List[Row]:
+        pdf = self.toPandas()

Review Comment:
   Can this be `None`?



##########
python/pyspark/sql/connect/dataframe.py:
##########
@@ -305,8 +308,12 @@ def _print_plan(self) -> str:
             return self._plan.print()
         return ""
 
-    def collect(self) -> None:
-        raise NotImplementedError("Please use toPandas().")
+    def collect(self) -> List[Row]:
+        pdf = self.toPandas()
+        if pdf is not None:
+            return list(pdf.apply(lambda fun: Row(*fun), axis=1))

Review Comment:
   ```suggestion
               return list(pdf.apply(lambda row: Row(*row), axis=1))
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org