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 @@ -22,7 +22,7 @@ import scala.collection.JavaConverters._
import org.apache.spark.annotation.Experimental
import org.apache.spark.api.java.function._
import org.apache.spark.sql.catalyst.encoders.{FlatEncoder, ExpressionEncoder, encoderFor}
import org.apache.spark.sql.catalyst.expressions.Attribute
import org.apache.spark.sql.catalyst.expressions.{Alias, CreateStruct, Attribute}
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.execution.QueryExecution

Expand Down Expand Up @@ -187,7 +187,12 @@ class GroupedDataset[K, T] private[sql](
val namedColumns =
columns.map(
_.withInputType(resolvedTEncoder, dataAttributes).named)
val aggregate = Aggregate(groupingAttributes, groupingAttributes ++ namedColumns, logicalPlan)
val keyColumn = if (groupingAttributes.length > 1) {
Alias(CreateStruct(groupingAttributes), "key")()
} else {
groupingAttributes.head
}
val aggregate = Aggregate(groupingAttributes, keyColumn +: namedColumns, logicalPlan)
val execution = new QueryExecution(sqlContext, aggregate)

new Dataset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
("a", 2), ("b", 3), ("c", 4))
}

ignore("Dataset should set the resolved encoders internally for maps") {
// TODO: Enable this once we fix SPARK-11793.
test("map and group by with class data") {
// We inject a group by here to make sure this test case is future proof
// when we implement better pipelining and local execution mode.
val ds: Dataset[(ClassData, Long)] = Seq(ClassData("one", 1), ClassData("two", 2)).toDS()
Expand All @@ -94,7 +93,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {

checkAnswer(
ds,
(ClassData("one", 1), 1L), (ClassData("two", 2), 1L))
(ClassData("one", 2), 1L), (ClassData("two", 3), 1L))
}

test("select") {
Expand Down