How can I sum multiple columns in Spark? For example, in SparkR the following code works to get the sum of one column, but if I try to get the sum of both columns in df, I get an error.
# Create SparkDataFrame df <- createDataFrame(faithful) # Use agg to sum total waiting times head(agg(df, totalWaiting = sum(df$waiting))) ##This works # Use agg to sum total of waiting and eruptions head(agg(df, total = sum(df$waiting, df$eruptions))) ##This doesn't work Either SparkR or PySpark code will work.