Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/9308#discussion_r43369777
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -1870,4 +1870,19 @@ class SQLQuerySuite extends QueryTest with
SharedSQLContext {
assert(sampled.count() == sampledOdd.count() + sampledEven.count())
}
}
+
+ test("SPARK-10707: nullability should be correctly propagated through
set operations") {
+ withTempTable("src") {
+ Seq((1, 1)).toDF("key", "value").registerTempTable("src")
+ checkAnswer(
+ sql("""SELECT count(v) FROM (
+ | SELECT v FROM (
+ | SELECT 'foo' AS v FROM src UNION ALL
+ | SELECT NULL AS v FROM src
+ | ) my_union WHERE isnull(v)
+ |) my_subview""".stripMargin),
+ Seq(Row(0)))
--- End diff --
This test doesn't look clear to me, how about:
```
checkAnswer(
sql(
"""
|SELECT a FROM (
| SELECT ISNULL(v) AS a, RAND() FROM (
| SELECT 'foo' AS v UNION ALL SELECT null AS v
| ) my_union
|) my_view
""".stripMargin),
Row(false) :: Row(true) :: Nil)
```
Use `RAND()` to stop column pruning for `Union` and then we can show that
`isnull(v)` is wrong because of the wrong nullability of `Union` output.
---
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]