zhengruifeng commented on code in PR #38549:
URL: https://github.com/apache/spark/pull/38549#discussion_r1017687960
##########
python/pyspark/sql/connect/dataframe.py:
##########
@@ -156,8 +156,53 @@ def count(self) -> int:
def crossJoin(self, other: "DataFrame") -> "DataFrame":
...
- def coalesce(self, num_partitions: int) -> "DataFrame":
- ...
+ def coalesce(self, numPartitions: int) -> "DataFrame":
+ """
+ Returns a new :class:`DataFrame` that has exactly `numPartitions`
partitions.
+
+ Coalesce does not trigger a shuffle.
+
+ .. versionadded:: 3.4.0
+
+ Parameters
+ ----------
+ numPartitions : int
+ specify the target number of partitions
+
+ Returns
+ -------
+ :class:`DataFrame`
+ """
+ if not numPartitions > 0:
+ raise ValueError("numPartitions must be positive.")
+ return DataFrame.withPlan(
+ plan.Repartition(self._plan, num_partitions=numPartitions,
shuffle=False),
+ self._session,
+ )
+
+ def repartition(self, numPartitions: int) -> "DataFrame":
Review Comment:
should support `*cols` after `repartitionByExpression` added
--
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]