208
208
# ' # Dataframe used throughout this doc
209
209
# ' df <- createDataFrame(cbind(model = rownames(mtcars), mtcars))
210
210
# ' tmp <- mutate(df, v1 = create_array(df$mpg, df$cyl, df$hp))
211
- # ' head(select(tmp, array_contains(tmp$v1, 21), size(tmp$v1)))
211
+ # ' head(select(tmp, array_contains(tmp$v1, 21), size(tmp$v1), shuffle(tmp$v1) ))
212
212
# ' head(select(tmp, array_max(tmp$v1), array_min(tmp$v1), array_distinct(tmp$v1)))
213
213
# ' head(select(tmp, array_position(tmp$v1, 21), array_repeat(df$mpg, 3), array_sort(tmp$v1)))
214
214
# ' head(select(tmp, flatten(tmp$v1), reverse(tmp$v1), array_remove(tmp$v1, 21)))
223
223
# ' head(select(tmp3, element_at(tmp3$v3, "Valiant")))
224
224
# ' tmp4 <- mutate(df, v4 = create_array(df$mpg, df$cyl), v5 = create_array(df$cyl, df$hp))
225
225
# ' head(select(tmp4, concat(tmp4$v4, tmp4$v5), arrays_overlap(tmp4$v4, tmp4$v5)))
226
+ # ' head(select(tmp4, array_except(tmp4$v4, tmp4$v5), array_intersect(tmp4$v4, tmp4$v5)))
227
+ # ' head(select(tmp4, array_union(tmp4$v4, tmp4$v5)))
226
228
# ' head(select(tmp4, arrays_zip(tmp4$v4, tmp4$v5), map_from_arrays(tmp4$v4, tmp4$v5)))
227
229
# ' head(select(tmp, concat(df$mpg, df$cyl, df$hp)))
228
230
# ' tmp5 <- mutate(df, v6 = create_array(df$model, df$model))
@@ -3024,6 +3026,34 @@ setMethod("array_distinct",
3024
3026
column(jc )
3025
3027
})
3026
3028
3029
+ # ' @details
3030
+ # ' \code{array_except}: Returns an array of the elements in the first array but not in the second
3031
+ # ' array, without duplicates. The order of elements in the result is not determined.
3032
+ # '
3033
+ # ' @rdname column_collection_functions
3034
+ # ' @aliases array_except array_except,Column-method
3035
+ # ' @note array_except since 2.4.0
3036
+ setMethod ("array_except ",
3037
+ signature(x = " Column" , y = " Column" ),
3038
+ function (x , y ) {
3039
+ jc <- callJStatic(" org.apache.spark.sql.functions" , " array_except" , x @ jc , y @ jc )
3040
+ column(jc )
3041
+ })
3042
+
3043
+ # ' @details
3044
+ # ' \code{array_intersect}: Returns an array of the elements in the intersection of the given two
3045
+ # ' arrays, without duplicates.
3046
+ # '
3047
+ # ' @rdname column_collection_functions
3048
+ # ' @aliases array_intersect array_intersect,Column-method
3049
+ # ' @note array_intersect since 2.4.0
3050
+ setMethod ("array_intersect ",
3051
+ signature(x = " Column" , y = " Column" ),
3052
+ function (x , y ) {
3053
+ jc <- callJStatic(" org.apache.spark.sql.functions" , " array_intersect" , x @ jc , y @ jc )
3054
+ column(jc )
3055
+ })
3056
+
3027
3057
# ' @details
3028
3058
# ' \code{array_join}: Concatenates the elements of column using the delimiter.
3029
3059
# ' Null values are replaced with nullReplacement if set, otherwise they are ignored.
@@ -3149,6 +3179,20 @@ setMethod("arrays_overlap",
3149
3179
column(jc )
3150
3180
})
3151
3181
3182
+ # ' @details
3183
+ # ' \code{array_union}: Returns an array of the elements in the union of the given two arrays,
3184
+ # ' without duplicates.
3185
+ # '
3186
+ # ' @rdname column_collection_functions
3187
+ # ' @aliases array_union array_union,Column-method
3188
+ # ' @note array_union since 2.4.0
3189
+ setMethod ("array_union ",
3190
+ signature(x = " Column" , y = " Column" ),
3191
+ function (x , y ) {
3192
+ jc <- callJStatic(" org.apache.spark.sql.functions" , " array_union" , x @ jc , y @ jc )
3193
+ column(jc )
3194
+ })
3195
+
3152
3196
# ' @details
3153
3197
# ' \code{arrays_zip}: Returns a merged array of structs in which the N-th struct contains all N-th
3154
3198
# ' values of input arrays.
@@ -3167,6 +3211,19 @@ setMethod("arrays_zip",
3167
3211
column(jc )
3168
3212
})
3169
3213
3214
+ # ' @details
3215
+ # ' \code{shuffle}: Returns a random permutation of the given array.
3216
+ # '
3217
+ # ' @rdname column_collection_functions
3218
+ # ' @aliases shuffle shuffle,Column-method
3219
+ # ' @note shuffle since 2.4.0
3220
+ setMethod ("shuffle ",
3221
+ signature(x = " Column" ),
3222
+ function (x ) {
3223
+ jc <- callJStatic(" org.apache.spark.sql.functions" , " shuffle" , x @ jc )
3224
+ column(jc )
3225
+ })
3226
+
3170
3227
# ' @details
3171
3228
# ' \code{flatten}: Creates a single array from an array of arrays.
3172
3229
# ' If a structure of nested arrays is deeper than two levels, only one level of nesting is removed.
0 commit comments