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 @@ -33,15 +33,14 @@ object Utils {
resultExpressions: Seq[NamedExpression],
child: SparkPlan): Seq[SparkPlan] = {

val groupingAttributes = groupingExpressions.map(_.toAttribute)
val completeAggregateExpressions = aggregateExpressions.map(_.copy(mode = Complete))
val completeAggregateAttributes = completeAggregateExpressions.map {
expr => aggregateFunctionToAttribute(expr.aggregateFunction, expr.isDistinct)
}

SortBasedAggregate(
requiredChildDistributionExpressions = Some(groupingAttributes),
groupingExpressions = groupingAttributes,
requiredChildDistributionExpressions = Some(groupingExpressions),
groupingExpressions = groupingExpressions,
nonCompleteAggregateExpressions = Nil,
nonCompleteAggregateAttributes = Nil,
completeAggregateExpressions = completeAggregateExpressions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ abstract class AggregationQuerySuite extends QueryTest with SQLTestUtils with Te
sqlContext.dropTempTable("emptyTable")
}

test("group by function") {
Seq((1, 2)).toDF("a", "b").registerTempTable("data")

checkAnswer(
sql("SELECT floor(a) AS a, collect_set(b) FROM data GROUP BY floor(a) ORDER BY a"),
Row(1, Array(2)) :: Nil)
}

test("empty table") {
// If there is no GROUP BY clause and the table is empty, we will generate a single row.
checkAnswer(
Expand Down