Skip to contents

Returns a new SparkDataFrame or a Column with an alias set. Equivalent to SQL "AS" keyword.

Usage

# S4 method for class 'Column'
alias(object, data)

# S4 method for class 'SparkDataFrame'
alias(object, data)

Arguments

object

x a SparkDataFrame or a Column

data

new name to use

Value

a SparkDataFrame or a Column

Note

alias(Column) since 1.4.0

alias(SparkDataFrame) since 2.3.0

Examples

if (FALSE) { # \dontrun{
df <- createDataFrame(iris)

head(select(
  df, alias(df$Sepal_Length, "slength"), alias(df$Petal_Length, "plength")
))
} # }
if (FALSE) { # \dontrun{
df <- alias(createDataFrame(mtcars), "mtcars")
avg_mpg <- alias(agg(groupBy(df, df$cyl), avg(df$mpg)), "avg_mpg")

head(select(df, column("mtcars.mpg")))
head(join(df, avg_mpg, column("mtcars.cyl") == column("avg_mpg.cyl")))
} # }