HyukjinKwon commented on code in PR #42770:
URL: https://github.com/apache/spark/pull/42770#discussion_r1314400083
##########
python/pyspark/sql/dataframe.py:
##########
@@ -1809,18 +1810,27 @@ def repartition( # type: ignore[misc]
Repartition the data into 10 partitions.
- >>> df.repartition(10).rdd.getNumPartitions()
- 10
+ >>> df.repartition(10).explain()
+ == Physical Plan ==
Review Comment:
One way for such cases is to use `foreachPartition` in that case with
printing each out. The problem would be the output wouldn't be caught in the
Python test (as they are printed out from a separate thread from JVM IIRC).
So, maybe we could do sth like:
```python
"""
>>> df = spark.createDataFrame([(14, "Tom"), (23, "Alice"), (16, "Bob")],
["age", "name"])
>>> df.repartition(2, "age").foreachPartition(lambda it: print(list(it))) #
doctest: +SKIP
[Row(age=14, name='Tom')]
[Row(age=23, name='Alice'), Row(age=16, name='Bob')]
...
"""
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]