Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,16 @@ class RelationalGroupedDataset protected[sql](
pivot(pivotColumn, values.asScala)
}

/**
* Returns all grouping column names as an array.
*
* @since 2.1.0
*/
def columns: Array[String] = {
val groupingNamedExpressions = groupingExprs.map(alias)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be a column (a named expression). Thus, this might not be useful to end users.

groupingNamedExpressions.map(_.name).toArray
}

/**
* Applies the given serialized R function `func` to each group of data. For each unique group,
* the function will be passed the group key and an iterator that contains all of the elements in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class DataFrameAggregateSuite extends QueryTest with SharedSQLContext {
Row(new java.math.BigDecimal(3.0), new java.math.BigDecimal(3.0)),
Row(null, new java.math.BigDecimal(2.0)))
)

assert(df1.groupBy("key").columns.sameElements(Array("key")))
assert(df1.groupBy("value1", "value2").columns.sameElements(Array("value1", "value2")))
}

test("SPARK-17124 agg should be ordering preserving") {
Expand Down