112112# ' df <- createDataFrame(cbind(model = rownames(mtcars), mtcars))
113113# ' tmp <- mutate(df, v1 = log(df$mpg), v2 = cbrt(df$disp),
114114# ' v3 = bround(df$wt, 1), v4 = bin(df$cyl),
115- # ' v5 = hex(df$wt), v6 = toDegrees (df$gear),
115+ # ' v5 = hex(df$wt), v6 = degrees (df$gear),
116116# ' v7 = atan2(df$cyl, df$am), v8 = hypot(df$cyl, df$am),
117117# ' v9 = pmod(df$hp, df$cyl), v10 = shiftLeft(df$disp, 1),
118118# ' v11 = conv(df$hp, 10, 16), v12 = sign(df$vs - 0.5),
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
@@ -319,23 +320,37 @@ setMethod("acos",
319320 })
320321
321322# ' @details
322- # ' \code{approxCountDistinct }: Returns the approximate number of distinct items in a group.
323+ # ' \code{approx_count_distinct }: Returns the approximate number of distinct items in a group.
323324# '
324325# ' @rdname column_aggregate_functions
325- # ' @aliases approxCountDistinct approxCountDistinct ,Column-method
326+ # ' @aliases approx_count_distinct approx_count_distinct ,Column-method
326327# ' @examples
327328# '
328329# ' \dontrun{
329- # ' head(select(df, approxCountDistinct (df$gear)))
330- # ' head(select(df, approxCountDistinct (df$gear, 0.02)))
330+ # ' head(select(df, approx_count_distinct (df$gear)))
331+ # ' head(select(df, approx_count_distinct (df$gear, 0.02)))
331332# ' head(select(df, countDistinct(df$gear, df$cyl)))
332333# ' head(select(df, n_distinct(df$gear)))
333334# ' head(distinct(select(df, "gear")))}
335+ # ' @note approx_count_distinct(Column) since 3.0.0
336+ setMethod ("approx_count_distinct ",
337+ signature(x = " Column" ),
338+ function (x ) {
339+ jc <- callJStatic(" org.apache.spark.sql.functions" , " approx_count_distinct" , x @ jc )
340+ column(jc )
341+ })
342+
343+ # ' @details
344+ # ' \code{approxCountDistinct}: Returns the approximate number of distinct items in a group.
345+ # '
346+ # ' @rdname column_aggregate_functions
347+ # ' @aliases approxCountDistinct approxCountDistinct,Column-method
334348# ' @note approxCountDistinct(Column) since 1.4.0
335349setMethod ("approxCountDistinct ",
336350 signature(x = " Column" ),
337351 function (x ) {
338- jc <- callJStatic(" org.apache.spark.sql.functions" , " approxCountDistinct" , x @ jc )
352+ .Deprecated(" approx_count_distinct" )
353+ jc <- callJStatic(" org.apache.spark.sql.functions" , " approx_count_distinct" , x @ jc )
339354 column(jc )
340355 })
341356
@@ -1650,7 +1665,22 @@ setMethod("tanh",
16501665setMethod ("toDegrees ",
16511666 signature(x = " Column" ),
16521667 function (x ) {
1653- jc <- callJStatic(" org.apache.spark.sql.functions" , " toDegrees" , x @ jc )
1668+ .Deprecated(" degrees" )
1669+ jc <- callJStatic(" org.apache.spark.sql.functions" , " degrees" , x @ jc )
1670+ column(jc )
1671+ })
1672+
1673+ # ' @details
1674+ # ' \code{degrees}: Converts an angle measured in radians to an approximately equivalent angle
1675+ # ' measured in degrees.
1676+ # '
1677+ # ' @rdname column_math_functions
1678+ # ' @aliases degrees degrees,Column-method
1679+ # ' @note degrees since 3.0.0
1680+ setMethod ("degrees ",
1681+ signature(x = " Column" ),
1682+ function (x ) {
1683+ jc <- callJStatic(" org.apache.spark.sql.functions" , " degrees" , x @ jc )
16541684 column(jc )
16551685 })
16561686
@@ -1664,7 +1694,22 @@ setMethod("toDegrees",
16641694setMethod ("toRadians ",
16651695 signature(x = " Column" ),
16661696 function (x ) {
1667- jc <- callJStatic(" org.apache.spark.sql.functions" , " toRadians" , x @ jc )
1697+ .Deprecated(" radians" )
1698+ jc <- callJStatic(" org.apache.spark.sql.functions" , " radians" , x @ jc )
1699+ column(jc )
1700+ })
1701+
1702+ # ' @details
1703+ # ' \code{radians}: Converts an angle measured in degrees to an approximately equivalent angle
1704+ # ' measured in radians.
1705+ # '
1706+ # ' @rdname column_math_functions
1707+ # ' @aliases radians radians,Column-method
1708+ # ' @note radians since 3.0.0
1709+ setMethod ("radians ",
1710+ signature(x = " Column" ),
1711+ function (x ) {
1712+ jc <- callJStatic(" org.apache.spark.sql.functions" , " radians" , x @ jc )
16681713 column(jc )
16691714 })
16701715
@@ -1740,6 +1785,26 @@ setMethod("to_json", signature(x = "Column"),
17401785 column(jc )
17411786 })
17421787
1788+ # ' @details
1789+ # ' \code{to_csv}: Converts a column containing a \code{structType} into a Column of CSV string.
1790+ # ' Resolving the Column can fail if an unsupported type is encountered.
1791+ # '
1792+ # ' @rdname column_collection_functions
1793+ # ' @aliases to_csv to_csv,Column-method
1794+ # ' @examples
1795+ # '
1796+ # ' \dontrun{
1797+ # ' # Converts a struct into a CSV string
1798+ # ' df2 <- sql("SELECT named_struct('date', cast('2000-01-01' as date)) as d")
1799+ # ' select(df2, to_csv(df2$d, dateFormat = 'dd/MM/yyyy'))}
1800+ # ' @note to_csv since 3.0.0
1801+ setMethod ("to_csv ", signature(x = "Column"),
1802+ function (x , ... ) {
1803+ options <- varargsToStrEnv(... )
1804+ jc <- callJStatic(" org.apache.spark.sql.functions" , " to_csv" , x @ jc , options )
1805+ column(jc )
1806+ })
1807+
17431808# ' @details
17441809# ' \code{to_timestamp}: Converts the column into a TimestampType. You may optionally specify
17451810# ' a format according to the rules in:
@@ -2044,13 +2109,24 @@ setMethod("pmod", signature(y = "Column"),
20442109
20452110# ' @param rsd maximum estimation error allowed (default = 0.05).
20462111# '
2112+ # ' @rdname column_aggregate_functions
2113+ # ' @aliases approx_count_distinct,Column-method
2114+ # ' @note approx_count_distinct(Column, numeric) since 3.0.0
2115+ setMethod ("approx_count_distinct ",
2116+ signature(x = " Column" ),
2117+ function (x , rsd = 0.05 ) {
2118+ jc <- callJStatic(" org.apache.spark.sql.functions" , " approx_count_distinct" , x @ jc , rsd )
2119+ column(jc )
2120+ })
2121+
20472122# ' @rdname column_aggregate_functions
20482123# ' @aliases approxCountDistinct,Column-method
20492124# ' @note approxCountDistinct(Column, numeric) since 1.4.0
20502125setMethod ("approxCountDistinct ",
20512126 signature(x = " Column" ),
20522127 function (x , rsd = 0.05 ) {
2053- jc <- callJStatic(" org.apache.spark.sql.functions" , " approxCountDistinct" , x @ jc , rsd )
2128+ .Deprecated(" approx_count_distinct" )
2129+ jc <- callJStatic(" org.apache.spark.sql.functions" , " approx_count_distinct" , x @ jc , rsd )
20542130 column(jc )
20552131 })
20562132
0 commit comments