Skip to content

Commit 673ef00

Browse files
committed
Improving comments
1 parent ef8e22a commit 673ef00

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sql/core/src/main/scala/org/apache/spark/sql/RelationalGroupedDataset.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ class RelationalGroupedDataset protected[sql](
331331
* df.groupBy("year").pivot("course").sum("earnings")
332332
* }}}
333333
*
334+
* From Spark 2.4.0, values can be literal columns, for instance, struct. For pivoting by
335+
* multiple columns, use the `struct` function to combine the columns and values:
336+
*
337+
* {{{
338+
* df.groupBy($"year")
339+
* .pivot("trainingCourse", Seq(struct(lit("java"), lit("Experts"))))
340+
* .agg(sum($"earnings"))
341+
* }}}
342+
*
334343
* @param pivotColumn Name of the column to pivot.
335344
* @param values List of values that will be translated to columns in the output DataFrame.
336345
* @since 1.6.0
@@ -407,14 +416,6 @@ class RelationalGroupedDataset protected[sql](
407416
* df.groupBy($"year").pivot($"course", Seq("dotNET", "Java")).sum($"earnings")
408417
* }}}
409418
*
410-
* For pivoting by multiple columns, use the `struct` function to combine the columns and values:
411-
*
412-
* {{{
413-
* df.groupBy($"year")
414-
* .pivot(struct($"course", $"training"), Seq(struct(lit("java"), lit("Experts"))))
415-
* .agg(sum($"earnings"))
416-
* }}}
417-
*
418419
* @param pivotColumn the column to pivot.
419420
* @param values List of values that will be translated to columns in the output DataFrame.
420421
* @since 2.4.0

0 commit comments

Comments
 (0)