diff options
author | Luciano Resende <lresende@apache.org> | 2016-04-07 08:35:00 +0800 |
---|---|---|
committer | Wenchen Fan <wenchen@databricks.com> | 2016-04-07 08:35:00 +0800 |
commit | 611dbce4bdd6f34ac1fa67d8dfa3d407600a0237 (patch) | |
tree | fac42e9037f6e8984665e3cb5e6ddd924a882289 | |
parent | bb873754b4700104755ab969694bf30945557dc3 (diff) | |
download | spark-611dbce4bdd6f34ac1fa67d8dfa3d407600a0237.tar.gz spark-611dbce4bdd6f34ac1fa67d8dfa3d407600a0237.tar.bz2 spark-611dbce4bdd6f34ac1fa67d8dfa3d407600a0237.zip |
[SPARK-12555][SQL] Result should not be corrupted after input columns are reordered
This PR add test case described in SPARK-12555 to validate that correct data is returned when input data is reordered and to avoid future regressions.
Author: Luciano Resende <lresende@apache.org>
Closes #11623 from lresende/SPARK-12555.
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/DatasetAggregatorSuite.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DatasetAggregatorSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DatasetAggregatorSuite.scala index 5430aff6ce..08b3389ad9 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/DatasetAggregatorSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/DatasetAggregatorSuite.scala @@ -84,6 +84,16 @@ object ComplexBufferAgg extends Aggregator[AggData, (Int, AggData), Int] { (b1._1 + b2._1, b1._2) } +object NameAgg extends Aggregator[AggData, String, String] { + def zero: String = "" + + def reduce(b: String, a: AggData): String = a.b + b + + def merge(b1: String, b2: String): String = b1 + b2 + + def finish(r: String): String = r +} + class DatasetAggregatorSuite extends QueryTest with SharedSQLContext { import testImplicits._ @@ -176,4 +186,13 @@ class DatasetAggregatorSuite extends QueryTest with SharedSQLContext { typed.avg(_._2), typed.count(_._2), typed.sum(_._2), typed.sumLong(_._2)), ("a", 2.0, 2L, 4.0, 4L), ("b", 3.0, 1L, 3.0, 3L)) } + + test("SPARK-12555 - result should not be corrupted after input columns are reordered") { + val ds = sql("SELECT 'Some String' AS b, 1279869254 AS a").as[AggData] + + checkDataset( + ds.groupByKey(_.a).agg(NameAgg.toColumn), + (1279869254, "Some String")) + } + } |