JacobZheng0927 commented on code in PR #43813:
URL: https://github.com/apache/spark/pull/43813#discussion_r1398808757
##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -1960,6 +1987,42 @@ class Dataset[T] private[sql](
toDF(), colNames.map(colName => resolve(colName)),
RelationalGroupedDataset.CubeType)
}
+ /**
+ * Create multi-dimensional aggregation for the current Dataset using the
specified grouping sets,
+ * so we can run aggregation on them.
+ * See [[RelationalGroupedDataset]] for all the available aggregate
functions.
+ *
+ * This is a variant of groupingSets that can only group by existing columns
using column names
+ * (i.e. cannot construct expressions).
+ *
+ * {{{
+ * // Compute the average for all numeric columns group by specific
grouping sets.
+ * ds.groupingSets(Seq(Seq("department", "group"),Seq()),"department",
"group").avg()
+ *
+ * // Compute the max age and average salary, group by specific grouping
sets.
+ * ds.groupingSets(Seq($"department", $"gender"), Seq($"department"),
Seq()).agg(Map(
+ * "salary" -> "avg",
+ * "age" -> "max"
+ * ))
+ * }}}
+ *
+ * @group untypedrel
+ * @since 4.0.0
+ */
+ @scala.annotation.varargs
+ def groupingSets(
+ groupingSets: Seq[Seq[String]],
Review Comment:
Are you saying that the methods using string columns are no longer needed,
and that I only need to keep the methods using columns of type Column?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]