Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/11285#discussion_r53562501
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SubquerySuite.scala
---
@@ -36,36 +36,39 @@ class SubquerySuite extends QueryTest with
SharedSQLContext {
sql("select (select (select 1) + 1) + 1").collect()
}
- // more than one columns
- val error = intercept[AnalysisException] {
- sql("select (select 1, 2) as b").collect()
- }
- assert(error.message contains "Scalar subquery must return only one
column, but got 2")
-
- // more than one rows
- val error2 = intercept[RuntimeException] {
- sql("select (select a from (select 1 as a union all select 2 as a)
t) as b").collect()
- }
- assert(error2.getMessage contains
- "more than one row returned by a subquery used as an expression")
-
// string type
assertResult(Array(Row("s"))) {
sql("select (select 's' as s) as b").collect()
}
+ }
- // zero rows
+ test("uncorrelated scalar subquery should return null if there is 0
rows") {
assertResult(Array(Row(null))) {
sql("select (select 's' as s limit 0) as b").collect()
}
}
+ test("analysis error when the number of columns is not 1") {
+ val error = intercept[AnalysisException] {
+ sql("select (select 1, 2) as b").collect()
+ }
+ assert(error.message.contains("Scalar subquery must return only one
column, but got 2"))
--- End diff --
These are already covered by AnasisErrorSuite, some one said that we don't
need to cover every corner cases by end-to-end query tests.
---
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]