Skip to contents

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

Usage

# S4 method for Column
alias(object, data)

# S4 method for 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) {
df <- createDataFrame(iris)

head(select(
  df, alias(df$Sepal_Length, "slength"), alias(df$Petal_Length, "plength")
))
}
if (FALSE) {
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")))
}