Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/10333#discussion_r47875650
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/DataFrameJoinSuite.scala ---
@@ -48,11 +48,13 @@ class DataFrameJoinSuite extends QueryTest with
SharedSQLContext {
checkAnswer(
df.join(df2, Seq("int", "str"), "left"),
- Row(1, 2, "1", null) :: Row(2, 3, "2", null) :: Row(3, 4, "3", null)
:: Nil)
+ Row(1, 2, "1", null, null, null) :: Row(2, 3, "2", null, null, null)
::
+ Row(3, 4, "3", null, null, null) :: Nil)
checkAnswer(
df.join(df2, Seq("int", "str"), "right"),
- Row(null, null, null, 2) :: Row(null, null, null, 3) :: Row(null,
null, null, 4) :: Nil)
+ Row(null, null, null, 1, 2, "2") :: Row(null, null, null, 2, 3, "3")
::
+ Row(null, null, null, 3, 4, "4") :: Nil)
--- End diff --
But there does exist bugs other than the nullability issue in the original
`DataFrame.join` method. For example it doesn't handle full outer join
correctly. Using the same example tables mentioned above, the following
`spark-shell` snippet
```scala
import sqlContext._
val t1 = table("t1")
val t2 = table("t2")
t1.join(t2, Seq("num"), "fullouter").show()
```
produces wrong query result:
```
+----+----+-----+
| num|name|value|
+----+----+-----+
| 1| a| xxx|
| 2| b| null|
| 3| c| yyy|
|null|null| zzz|
+----+----+-----+
```
Here's the result from PostgreSQL:
```
postgres=# SELECT * FROM t1 FULL JOIN t2 USING (num);
num | name | value
-----+------+-------
1 | a | xxx
2 | b |
3 | c | yyy
5 | | zzz
(4 rows)
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]