dropFields {SparkR}R Documentation

dropFields

Description

Drops fields in a struct Column by name.

Usage

dropFields(x, ...)

## S4 method for signature 'Column'
dropFields(x, ...)

Arguments

x

a Column

...

names of the fields to be dropped.

Note

dropFields since 3.1.0

Examples

## Not run: 
##D df <- select(
##D   createDataFrame(iris),
##D   alias(
##D     struct(
##D       column("Sepal_Width"), column("Sepal_Length"),
##D       alias(
##D         struct(
##D           column("Petal_Width"), column("Petal_Length"),
##D           alias(
##D             column("Petal_Width") * column("Petal_Length"),
##D             "Petal_Product"
##D           )
##D         ),
##D         "Petal"
##D       )
##D     ),
##D     "dimensions"
##D   )
##D )
##D head(withColumn(df, "dimensions", dropFields(df$dimensions, "Petal")))
##D 
##D head(
##D   withColumn(
##D     df, "dimensions",
##D     dropFields(df$dimensions, "Sepal_Width", "Sepal_Length")
##D   )
##D )
##D 
##D # This method supports dropping multiple nested fields directly e.g.
##D head(
##D   withColumn(
##D     df, "dimensions",
##D     dropFields(df$dimensions, "Petal.Petal_Width", "Petal.Petal_Length")
##D   )
##D )
##D 
##D # However, if you are going to add/replace multiple nested fields,
##D # it is preferred to extract out the nested struct before
##D # adding/replacing multiple fields e.g.
##D head(
##D   withColumn(
##D     df, "dimensions",
##D     withField(
##D       column("dimensions"),
##D       "Petal",
##D       dropFields(column("dimensions.Petal"), "Petal_Width", "Petal_Length")
##D     )
##D   )
##D )
## End(Not run)

[Package SparkR version 3.2.0 Index]