Pass List[String] or Seq[String] to groupBy in spark

Viewed 4047

df.groupBy("col1", "col2", "col3") works perfectly fine.

But when I try to do the following:

val dimensions = Seq("col1", "col2", "col3")
df.groupBy(dimensions)

I'm getting this error:

<console>:38: error: overloaded method value groupBy with alternatives:
  (col1: String,cols: String*)org.apache.spark.sql.GroupedData <and>
  (cols: org.apache.spark.sql.Column*)org.apache.spark.sql.GroupedData
 cannot be applied to (Seq[String])
1 Answers
Related