Skip to content

Commit 2a0b65b

Browse files
committed
Moving from_csv closer to from_json and fixing warnings
1 parent 42b8227 commit 2a0b65b

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

R/pkg/R/functions.R

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ NULL
188188
#' \item \code{to_json}: it is the column containing the struct, array of the structs,
189189
#' the map or array of maps.
190190
#' \item \code{from_json}: it is the column containing the JSON string.
191+
#' \item \code{from_csv}: it is the column containing the CSV string.
191192
#' }
192193
#' @param y Column to compute on.
193194
#' @param value A value to compute on.
@@ -2202,6 +2203,25 @@ setMethod("from_json", signature(x = "Column", schema = "characterOrstructType")
22022203
column(jc)
22032204
})
22042205

2206+
#' @details
2207+
#' \code{from_csv}: Parses a column containing a CSV string into a Column of \code{structType}
2208+
#' with the specified \code{schema}.
2209+
#' If the string is unparseable, the Column will contain the value NA.
2210+
#'
2211+
#' @rdname column_collection_functions
2212+
#' @param schema a DDL-formatted string
2213+
#' @aliases from_csv from_csv,Column,character-method
2214+
#'
2215+
#' @note from_csv since 3.0.0
2216+
setMethod("from_csv", signature(x = "Column", schema = "character"),
2217+
function(x, schema, ...) {
2218+
options <- varargsToStrEnv(...)
2219+
jc <- callJStatic("org.apache.spark.sql.functions",
2220+
"from_csv",
2221+
x@jc, schema, options)
2222+
column(jc)
2223+
})
2224+
22052225
#' @details
22062226
#' \code{from_utc_timestamp}: Given a timestamp like '2017-07-14 02:40:00.0', interprets it as a
22072227
#' time in UTC, and renders that time as a timestamp in the given time zone. For example, 'GMT+1'
@@ -3720,24 +3740,3 @@ setMethod("current_timestamp",
37203740
jc <- callJStatic("org.apache.spark.sql.functions", "current_timestamp")
37213741
column(jc)
37223742
})
3723-
3724-
#' @details
3725-
#' \code{from_csv}: Parses a column containing a CSV string into a Column of \code{structType}
3726-
#' with the specified \code{schema}.
3727-
#' If the string is unparseable, the Column will contain the value NA.
3728-
#'
3729-
#' @rdname column_collection_functions
3730-
#' @param schema a DDL-formatted string
3731-
#' @param ... options for CSV parser. Supported the same options as for CSV data source
3732-
#' @aliases from_csv from_csv,Column,character-method
3733-
#'
3734-
#' @note from_csv since 3.0.0
3735-
setMethod("from_csv", signature(x = "Column", schema = "character"),
3736-
function(x, schema, ...) {
3737-
options <- varargsToStrEnv(...)
3738-
jc <- callJStatic("org.apache.spark.sql.functions",
3739-
"from_csv",
3740-
x@jc, schema, options)
3741-
column(jc)
3742-
})
3743-

0 commit comments

Comments
 (0)