Github user felixcheung commented on a diff in the pull request:
https://github.com/apache/spark/pull/16138#discussion_r97463139
--- Diff: R/pkg/R/functions.R ---
@@ -1730,24 +1730,82 @@ setMethod("toRadians",
#' to_date
#'
-#' Converts the column into DateType.
+#' Converts the column into DateType, optionally with a format. Returns
null if input is invalid.
+#' Specify formats according to:
http://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html
#'
-#' @param x Column to compute on.
+#' @param x Column to parse.
+#' @param format string to use to parse x Column to DateType.
#'
#' @rdname to_date
#' @name to_date
#' @family datetime_funcs
#' @aliases to_date,Column-method
#' @export
-#' @examples \dontrun{to_date(df$c)}
-#' @note to_date since 1.5.0
+#' @examples
+#' \dontrun{
+#' to_date(df$c)
+#' to_date(df$c, 'yyyy-MM-dd')
+#' }
+#' @note to_date(Column, format) since 2.2.0
setMethod("to_date",
- signature(x = "Column"),
- function(x) {
+ signature(x = "Column", format = "missing"),
+ function(x, format) {
jc <- callJStatic("org.apache.spark.sql.functions", "to_date",
x@jc)
column(jc)
})
+#' @rdname to_date
+#' @name to_date
+#' @family datetime_funcs
+#' @aliases to_date,Column-method,character-method
+#' @export
+#' @note to_date(Column, format) since 2.2.0
+setMethod("to_date",
+signature(x = "Column", format = "character"),
+function(x, format) {
+ jc <- callJStatic("org.apache.spark.sql.functions", "to_date", x@jc,
format)
+ column(jc)
+})
+
+#' to_timestamp
+#'
+#' Converts the column into DateType, optionally with a format. Returns
null if input is invalid.
+#' Specify formats according to:
http://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html
--- End diff --
ditto on the description
---
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]