Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16668#discussion_r97209653
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -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))
    --- End diff --
    
    Right, we agreed.
    The conversion, especially into RRDD, is in particular concerning. From 
what I can see though this `df.rdd.getNumPartitions` is the recommended 
practice, which seems to be all over pyspark. (granted, DataFrame to RDD in 
pyspark is likely slightly more efficient) 
    
    An alternative, is we could wrap all of this on the JVM side - at least 
that should save us the around trip to RRDD.
    
    But agreed, is there a more efficient way this could be exposed in 
DataFrame/Dataset directly instead?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to