-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22920][SPARKR] sql functions for current_date, current_timestamp, rtrim/ltrim/trim with trimString #20105
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,3 +59,4 @@ Collate: | |
| 'window.R' | ||
| RoxygenNote: 5.0.1 | ||
| VignetteBuilder: knitr | ||
| NeedsCompilation: no | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,8 @@ NULL | |
| #' Date time functions defined for \code{Column}. | ||
| #' | ||
| #' @param x Column to compute on. In \code{window}, it must be a time Column of | ||
| #' \code{TimestampType}. | ||
| #' \code{TimestampType}. This is not used with \code{current_date} and | ||
| #' \code{current_timestamp} | ||
| #' @param format The format for the given dates or timestamps in Column \code{x}. See the | ||
| #' format used in the following methods: | ||
| #' \itemize{ | ||
|
|
@@ -1109,10 +1110,11 @@ setMethod("lower", | |
| }) | ||
|
|
||
| #' @details | ||
| #' \code{ltrim}: Trims the spaces from left end for the specified string value. | ||
| #' \code{ltrim}: Trims the spaces from left end for the specified string value. Optionally a | ||
| #' \code{trimString} can be specified. | ||
| #' | ||
| #' @rdname column_string_functions | ||
| #' @aliases ltrim ltrim,Column-method | ||
| #' @aliases ltrim ltrim,Column,missing-method | ||
| #' @export | ||
| #' @examples | ||
| #' | ||
|
|
@@ -1128,12 +1130,24 @@ setMethod("lower", | |
| #' head(tmp)} | ||
| #' @note ltrim since 1.5.0 | ||
| setMethod("ltrim", | ||
| signature(x = "Column"), | ||
| function(x) { | ||
| signature(x = "Column", trimString = "missing"), | ||
| function(x, trimString) { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "ltrim", x@jc) | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @param trimString a character string to trim with | ||
| #' @rdname column_string_functions | ||
| #' @aliases ltrim,Column,character-method | ||
| #' @export | ||
| #' @note ltrim(Column, character) since 2.3.0 | ||
| setMethod("ltrim", | ||
| signature(x = "Column", trimString = "character"), | ||
| function(x, trimString) { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "ltrim", x@jc, trimString) | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @details | ||
| #' \code{max}: Returns the maximum value of the expression in a group. | ||
| #' | ||
|
|
@@ -1348,19 +1362,31 @@ setMethod("bround", | |
| }) | ||
|
|
||
| #' @details | ||
| #' \code{rtrim}: Trims the spaces from right end for the specified string value. | ||
| #' \code{rtrim}: Trims the spaces from right end for the specified string value. Optionally a | ||
| #' \code{trimString} can be specified. | ||
| #' | ||
| #' @rdname column_string_functions | ||
| #' @aliases rtrim rtrim,Column-method | ||
| #' @aliases rtrim rtrim,Column,missing-method | ||
| #' @export | ||
| #' @note rtrim since 1.5.0 | ||
| setMethod("rtrim", | ||
| signature(x = "Column"), | ||
| function(x) { | ||
| signature(x = "Column", trimString = "missing"), | ||
| function(x, trimString) { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "rtrim", x@jc) | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @rdname column_string_functions | ||
| #' @aliases rtrim,Column,character-method | ||
| #' @export | ||
| #' @note rtrim(Column, character) since 2.3.0 | ||
| setMethod("rtrim", | ||
| signature(x = "Column", trimString = "character"), | ||
| function(x, trimString) { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "rtrim", x@jc, trimString) | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @details | ||
| #' \code{sd}: Alias for \code{stddev_samp}. | ||
| #' | ||
|
|
@@ -1789,19 +1815,31 @@ setMethod("to_timestamp", | |
| }) | ||
|
|
||
| #' @details | ||
| #' \code{trim}: Trims the spaces from both ends for the specified string column. | ||
| #' \code{trim}: Trims the spaces from both ends for the specified string column. Optionally a | ||
| #' \code{trimString} can be specified. | ||
| #' | ||
| #' @rdname column_string_functions | ||
| #' @aliases trim trim,Column-method | ||
| #' @aliases trim trim,Column,missing-method | ||
| #' @export | ||
| #' @note trim since 1.5.0 | ||
| setMethod("trim", | ||
| signature(x = "Column"), | ||
| function(x) { | ||
| signature(x = "Column", trimString = "missing"), | ||
| function(x, trimString) { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "trim", x@jc) | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @rdname column_string_functions | ||
| #' @aliases trim,Column,character-method | ||
| #' @export | ||
| #' @note trim(Column, character) since 2.3.0 | ||
| setMethod("trim", | ||
| signature(x = "Column", trimString = "character"), | ||
| function(x, trimString) { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "trim", x@jc, trimString) | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @details | ||
| #' \code{unbase64}: Decodes a BASE64 encoded string column and returns it as a binary column. | ||
| #' This is the reverse of base64. | ||
|
|
@@ -2777,11 +2815,11 @@ setMethod("rpad", signature(x = "Column", len = "numeric", pad = "character"), | |
| }) | ||
|
|
||
| #' @details | ||
| #' \code{substring_index}: Returns the substring from string str before count occurrences of | ||
| #' the delimiter delim. If count is positive, everything the left of the final delimiter | ||
| #' (counting from left) is returned. If count is negative, every to the right of the final | ||
| #' delimiter (counting from the right) is returned. substring_index performs a case-sensitive | ||
| #' match when searching for delim. | ||
| #' \code{substring_index}: Returns the substring from string (\code{x}) before \code{count} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is mainly to fix the reference to |
||
| #' occurrences of the delimiter (\code{delim}). If \code{count} is positive, everything the left of | ||
| #' the final delimiter (counting from left) is returned. If \code{count} is negative, every to the | ||
| #' right of the final delimiter (counting from the right) is returned. \code{substring_index} | ||
| #' performs a case-sensitive match when searching for the delimiter. | ||
| #' | ||
| #' @param delim a delimiter string. | ||
| #' @param count number of occurrences of \code{delim} before the substring is returned. | ||
|
|
@@ -3504,3 +3542,34 @@ setMethod("date_trunc", | |
| jc <- callJStatic("org.apache.spark.sql.functions", "date_trunc", format, x@jc) | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @details | ||
| #' \code{current_date}: Returns the current date as a date column. | ||
| #' | ||
| #' @rdname column_datetime_functions | ||
| #' @aliases current_date current_date,missing-method | ||
| #' @export | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' head(select(df, current_date(), current_timestamp()))} | ||
| #' @note current_date since 2.3.0 | ||
| setMethod("current_date", | ||
| signature("missing"), | ||
| function() { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "current_date") | ||
| column(jc) | ||
| }) | ||
|
|
||
| #' @details | ||
| #' \code{current_timestamp}: Returns the current timestamp as a timestamp column. | ||
| #' | ||
| #' @rdname column_datetime_functions | ||
| #' @aliases current_timestamp current_timestamp,missing-method | ||
| #' @export | ||
| #' @note current_timestamp since 2.3.0 | ||
| setMethod("current_timestamp", | ||
| signature("missing"), | ||
| function() { | ||
| jc <- callJStatic("org.apache.spark.sql.functions", "current_timestamp") | ||
| column(jc) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this gets flagged from CRAN when submitted