Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/13774#discussion_r67672158
--- Diff: R/pkg/R/functions.R ---
@@ -911,6 +911,33 @@ setMethod("minute",
column(jc)
})
+#' monotonically_increasing_id
+#'
+#' Return a column that generates monotonically increasing 64-bit integers.
+#'
+#' The generated ID is guaranteed to be monotonically increasing and
unique, but not consecutive.
+#' The current implementation puts the partition ID in the upper 31 bits,
and the record number
+#' within each partition in the lower 33 bits. The assumption is that the
data frame has
+#' less than 1 billion partitions, and each partition has less than 8
billion records.
+#'
+#' As an example, consider a SparkDataFrame with two partitions, each with
3 records.
+#' This expression would return the following IDs:
+#' 0, 1, 2, 8589934592 (1L << 33), 8589934593, 8589934594.
+#'
+#' This is equivalent to the MONOTONICALLY_INCREASING_ID function in SQL.
+#'
+#' @rdname monotonically_increasing_id
+#' @name monotonically_increasing_id
+#' @family misc_funcs
+#' @export
+#' @examples \dontrun{select(df, monotonically_increasing_id())}
+setMethod("monotonically_increasing_id",
+ signature(x = "missing"),
+ function(x) {
--- End diff --
Oops. Sure!
---
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]