-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18788][SPARKR] Add API for getNumPartitions #16668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3406,3 +3406,28 @@ setMethod("randomSplit", | |
| } | ||
| sapply(sdfs, dataFrame) | ||
| }) | ||
|
|
||
| #' getNumPartitions | ||
| #' | ||
| #' Return the number of partitions | ||
| #' Note: in order to compute the number of partition the SparkDataFrame has to be converted into a | ||
| #' RDD temporarily internally. | ||
| #' | ||
| #' @param x A SparkDataFrame | ||
| #' @family SparkDataFrame functions | ||
| #' @aliases getNumPartitions,SparkDataFrame-method | ||
| #' @rdname getNumPartitions | ||
| #' @name getNumPartitions | ||
| #' @export | ||
| #' @examples | ||
| #'\dontrun{ | ||
| #' sparkR.session() | ||
| #' df <- createDataFrame(cars, numPartitions = 2) | ||
| #' getNumPartitions(df) | ||
| #' } | ||
| #' @note getNumPartitions since 2.1.1 | ||
| setMethod("getNumPartitions", | ||
| signature(x = "SparkDataFrame"), | ||
| function(x) { | ||
| getNumPartitionsRDD(toRDD(x)) | ||
|
||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixcheung, should this be
since 2.2.0? Just curious.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated about this quite a bit - generally it should but we merged createDataFrame(..., numPartitions) to 2.1 and it felt important to have a getNumPartition in the same release too.