|
221 | 221 | #' head(select(tmp3, element_at(tmp3$v3, "Valiant"))) |
222 | 222 | #' tmp4 <- mutate(df, v4 = create_array(df$mpg, df$cyl), v5 = create_array(df$cyl, df$hp)) |
223 | 223 | #' head(select(tmp4, concat(tmp4$v4, tmp4$v5), arrays_overlap(tmp4$v4, tmp4$v5))) |
224 | | -#' head(select(tmp, concat(df$mpg, df$cyl, df$hp)))} |
| 224 | +#' head(select(tmp, concat(df$mpg, df$cyl, df$hp))) |
| 225 | +#' tmp5 <- mutate(df, v6 = create_array(df$model, df$model)) |
| 226 | +#' head(select(tmp5, array_join(tmp5$v6, "#"), array_join(tmp5$v6, "#", "NULL")))} |
225 | 227 | NULL |
226 | 228 |
|
227 | 229 | #' Window functions for Column operations |
@@ -3006,6 +3008,27 @@ setMethod("array_contains", |
3006 | 3008 | column(jc) |
3007 | 3009 | }) |
3008 | 3010 |
|
| 3011 | +#' @details |
| 3012 | +#' \code{array_join}: Concatenates the elements of column using the delimiter. |
| 3013 | +#' Null values are replaced with nullReplacement if set, otherwise they are ignored. |
| 3014 | +#' |
| 3015 | +#' @param delimiter a character string that is used to concatenate the elements of column. |
| 3016 | +#' @param nullReplacement an optional character string that is used to replace the Null values. |
| 3017 | +#' @rdname column_collection_functions |
| 3018 | +#' @aliases array_join array_join,Column-method |
| 3019 | +#' @note array_join since 2.4.0 |
| 3020 | +setMethod("array_join", |
| 3021 | + signature(x = "Column", delimiter = "character"), |
| 3022 | + function(x, delimiter, nullReplacement = NULL) { |
| 3023 | + jc <- if (is.null(nullReplacement)) { |
| 3024 | + callJStatic("org.apache.spark.sql.functions", "array_join", x@jc, delimiter) |
| 3025 | + } else { |
| 3026 | + callJStatic("org.apache.spark.sql.functions", "array_join", x@jc, delimiter, |
| 3027 | + as.character(nullReplacement)) |
| 3028 | + } |
| 3029 | + column(jc) |
| 3030 | + }) |
| 3031 | + |
3009 | 3032 | #' @details |
3010 | 3033 | #' \code{array_max}: Returns the maximum value of the array. |
3011 | 3034 | #' |
@@ -3197,8 +3220,8 @@ setMethod("size", |
3197 | 3220 | #' (or starting from the end if start is negative) with the specified length. |
3198 | 3221 | #' |
3199 | 3222 | #' @rdname column_collection_functions |
3200 | | -#' @param start an index indicating the first element occuring in the result. |
3201 | | -#' @param length a number of consecutive elements choosen to the result. |
| 3223 | +#' @param start an index indicating the first element occurring in the result. |
| 3224 | +#' @param length a number of consecutive elements chosen to the result. |
3202 | 3225 | #' @aliases slice slice,Column-method |
3203 | 3226 | #' @note slice since 2.4.0 |
3204 | 3227 | setMethod("slice", |
|
0 commit comments