aboutsummaryrefslogtreecommitdiff
path: root/sql/core/src/test
diff options
context:
space:
mode:
authorWenchen Fan <wenchen@databricks.com>2015-11-03 12:47:39 +0100
committerMichael Armbrust <michael@databricks.com>2015-11-03 12:47:39 +0100
commit425ff03f5ac4f3ddda1ba06656e620d5426f4209 (patch)
treeb4502d3db6c249c2d2b3de0b49f3c3afda66964a /sql/core/src/test
parent67e23b39ac3cdee06668fa9131951278b9731e29 (diff)
downloadspark-425ff03f5ac4f3ddda1ba06656e620d5426f4209.tar.gz
spark-425ff03f5ac4f3ddda1ba06656e620d5426f4209.tar.bz2
spark-425ff03f5ac4f3ddda1ba06656e620d5426f4209.zip
[SPARK-11436] [SQL] rebind right encoder when join 2 datasets
When we join 2 datasets, we will combine 2 encoders into a tupled one, and use it as the encoder for the jioned dataset. Assume both of the 2 encoders are flat, their `constructExpression`s both reference to the first element of input row. However, when we combine 2 encoders, the schema of input row changed, now the right encoder should reference to second element of input row. So we should rebind right encoder to let it know the new schema of input row before combine it. Author: Wenchen Fan <wenchen@databricks.com> Closes #9391 from cloud-fan/join and squashes the following commits: 846d3ab [Wenchen Fan] rebind right encoder when join 2 datasets
Diffstat (limited to 'sql/core/src/test')
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
index 993e6d269e..95b8d05cf4 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
@@ -214,4 +214,12 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
cogrouped,
1 -> "a#", 2 -> "#q", 3 -> "abcfoo#w", 5 -> "hello#er")
}
+
+ test("SPARK-11436: we should rebind right encoder when join 2 datasets") {
+ val ds1 = Seq("1", "2").toDS().as("a")
+ val ds2 = Seq(2, 3).toDS().as("b")
+
+ val joined = ds1.joinWith(ds2, $"a.value" === $"b.value")
+ checkAnswer(joined, ("2", 2))
+ }
}