nchammas commented on code in PR #45363:
URL: https://github.com/apache/spark/pull/45363#discussion_r1510555559
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/RelationalGroupedDataset.scala:
##########
@@ -259,18 +259,19 @@ class RelationalGroupedDataset private[sql] (
/**
* Pivots a column of the current `DataFrame` and performs the specified
aggregation.
*
- * There are two versions of `pivot` function: one that requires the caller
to specify the list
- * of distinct values to pivot on, and one that does not. The latter is more
concise but less
- * efficient, because Spark needs to first compute the list of distinct
values internally.
- *
* {{{
* // Compute the sum of earnings for each year by course with each course
as a separate column
- * df.groupBy("year").pivot("course", Seq("dotNET",
"Java")).sum("earnings")
- *
- * // Or without specifying column values (less efficient)
* df.groupBy("year").pivot("course").sum("earnings")
* }}}
*
+ * @note
Review Comment:
I trimmed the note a bit. Is that better?
I also took a look at the CSV reader method:
https://github.com/apache/spark/blob/a1b0da200b271214e9d6b3170308509d7d514c7f/sql/core/src/main/scala/org/apache/spark/sql/DataFrameReader.scala#L530-L532
It's pretty similar to what I'm proposing here.
I believe it's more important to highlight the eager computation here since
`pivot` is a transformation and, unlike with reader methods, users are probably
not expecting expensive computations to be triggered. But I agree, we don't
want to make it sound like there's something _wrong_ with not specifying pivot
values.
--
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]