alias()
function in Spark is used to rename a column or an expression in a DataFrame. It is particularly useful when you want to give a more meaningful name to a column, especially after performing transformations or aggregations. The alias()
function can be applied to columns, expressions, or even entire DataFrames.
Column
object with the new name.alias()
with Aggregationsalias()
is lightweight and does not involve data movement.alias()
function is used to rename columns, expressions, or DataFrames.AS
.