-
- Downloads
[SPARK-18863][SQL] Output non-aggregate expressions without GROUP BY in a...
[SPARK-18863][SQL] Output non-aggregate expressions without GROUP BY in a subquery does not yield an error ## What changes were proposed in this pull request? This PR will report proper error messages when a subquery expression contain an invalid plan. This problem is fixed by calling CheckAnalysis for the plan inside a subquery. ## How was this patch tested? Existing tests and two new test cases on 2 forms of subquery, namely, scalar subquery and in/exists subquery. ```` -- TC 01.01 -- The column t2b in the SELECT of the subquery is invalid -- because it is neither an aggregate function nor a GROUP BY column. select t1a, t2b from t1, t2 where t1b = t2c and t2b = (select max(avg) from (select t2b, avg(t2b) avg from t2 where t2a = t1.t1b ) ) ; -- TC 01.02 -- Invalid due to the column t2b not part of the output from table t2. select * from t1 where t1a in (select min(t2a) from t2 group by t2c having t2c in (select max(t3c) from t3 group by t3b having t3b > t2b )) ; ```` Author: Nattavut Sutyanyong <nsy.can@gmail.com> Closes #16572 from nsyca/18863. (cherry picked from commit f1ddca5f) Signed-off-by:Herman van Hovell <hvanhovell@databricks.com>
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala 56 additions, 50 deletions...rg/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
- sql/core/src/test/resources/sql-tests/inputs/subquery/negative-cases/invalid-correlation.sql 42 additions, 0 deletions...ts/inputs/subquery/negative-cases/invalid-correlation.sql
- sql/core/src/test/resources/sql-tests/results/subquery/negative-cases/invalid-correlation.sql.out 66 additions, 0 deletions...sults/subquery/negative-cases/invalid-correlation.sql.out
- sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala 4 additions, 1 deletion...c/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
Loading
Please register or sign in to comment