187187# ' \itemize{
188188# ' \item \code{to_json}: it is the column containing the struct, array of the structs,
189189# ' the map or array of maps.
190+ # ' \item \code{to_csv}: it is the column containing the struct.
190191# ' \item \code{from_json}: it is the column containing the JSON string.
191192# ' \item \code{from_csv}: it is the column containing the CSV string.
192193# ' }
@@ -204,11 +205,11 @@ NULL
204205# ' also supported for the schema.
205206# ' \item \code{from_csv}: a DDL-formatted string
206207# ' }
207- # ' @param ... additional argument(s). In \code{to_json} and \code{from_json}, this contains
208- # ' additional named properties to control how it is converted, accepts the same
209- # ' options as the JSON data source. Additionally \code{to_json} supports the "pretty"
210- # ' option which enables pretty JSON generation. In \code{arrays_zip}, this contains
211- # ' additional Columns of arrays to be merged.
208+ # ' @param ... additional argument(s). In \code{to_json}, \code{to_csv} and \code{from_json},
209+ # ' this contains additional named properties to control how it is converted, accepts
210+ # ' the same options as the JSON/CSV data source. Additionally \code{to_json} supports
211+ # ' the "pretty" option which enables pretty JSON generation. In \code{arrays_zip},
212+ # ' this contains additional Columns of arrays to be merged.
212213# ' @name column_collection_functions
213214# ' @rdname column_collection_functions
214215# ' @family collection functions
@@ -1740,6 +1741,26 @@ setMethod("to_json", signature(x = "Column"),
17401741 column(jc )
17411742 })
17421743
1744+ # ' @details
1745+ # ' \code{to_csv}: Converts a column containing a \code{structType} into a Column of CSV string.
1746+ # ' Resolving the Column can fail if an unsupported type is encountered.
1747+ # '
1748+ # ' @rdname column_collection_functions
1749+ # ' @aliases to_csv to_csv,Column-method
1750+ # ' @examples
1751+ # '
1752+ # ' \dontrun{
1753+ # ' # Converts a struct into a CSV string
1754+ # ' df2 <- sql("SELECT named_struct('date', cast('2000-01-01' as date)) as d")
1755+ # ' select(df2, to_csv(df2$d, dateFormat = 'dd/MM/yyyy'))}
1756+ # ' @note to_csv since 3.0.0
1757+ setMethod ("to_csv ", signature(x = "Column"),
1758+ function (x , ... ) {
1759+ options <- varargsToStrEnv(... )
1760+ jc <- callJStatic(" org.apache.spark.sql.functions" , " to_csv" , x @ jc , options )
1761+ column(jc )
1762+ })
1763+
17431764# ' @details
17441765# ' \code{to_timestamp}: Converts the column into a TimestampType. You may optionally specify
17451766# ' a format according to the rules in:
0 commit comments