Github user sun-rui commented on a diff in the pull request:
https://github.com/apache/spark/pull/9196#discussion_r43349308
--- Diff: R/pkg/R/functions.R ---
@@ -2111,3 +2133,66 @@ setMethod("ntile",
jc <- callJStatic("org.apache.spark.sql.functions", "ntile",
as.integer(x))
column(jc)
})
+
+#' percentRank
+#'
+#' Window function: returns the relative rank (i.e. percentile) of rows
within a window partition.
+#'
+#' This is computed by:
+#'
+#' (rank of row in its partition - 1) / (number of rows in the partition
- 1)
+#'
+#' This is equivalent to the PERCENT_RANK function in SQL.
+#'
+#' @rdname percentRank
+#' @name percentRank
+#' @family window_funcs
+#' @export
+#' @examples \dontrun{percentRank()}
+setMethod("percentRank",
+ signature(x = "missing"),
+ function() {
+ jc <- callJStatic("org.apache.spark.sql.functions",
"percentRank")
+ column(jc)
+ })
+
+#' rank
+#'
+#' Window function: returns the rank of rows within a window partition.
+#'
+#' The difference between rank and denseRank is that denseRank leaves no
gaps in ranking
+#' sequence when there are ties. That is, if you were ranking a
competition using denseRank
+#' and had three people tie for second place, you would say that all three
were in second
+#' place and that the next person came in third.
+#'
+#' This is equivalent to the RANK function in SQL.
+#'
+#' @rdname rank
+#' @name rank
+#' @family window_funcs
+#' @export
+#' @examples \dontrun{rank()}
+setMethod("rank",
+ signature(x = "missing"),
+ function() {
+ jc <- callJStatic("org.apache.spark.sql.functions", "rank")
+ column(jc)
+ })
+
+#' rowNumber
+#'
+#' Window function: returns a sequential number starting at 1 within a
window partition.
+#'
+#' This is equivalent to the ROW_NUMBER function in SQL.
+#'
+#' @rdname rowNumber
+#' @name rowNumber
+#' @family window_funcs
+#' @export
+#' @examples \dontrun{rowNumber()}
--- End diff --
these functions should work with over clause and window specification,
which have not been enabled in SparkR. I will submit a JIRA issue for it and we
can add example in PR for that JIRA.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]