GitHub user davies opened a pull request:
https://github.com/apache/spark/pull/10706
[SPARK-12543] [SQL] [WIP] Subquery in expression
This PR brings subquery for expression (use subquery as an expression
inside SELECT/WHERE/HAVING), for example:
```
select (select 1) as a
select * from t where a = (select max(b) from t2)
select * from t where exists (select * from t2 where t2.b = t.b)
select max(a) as ma from t having ma = (select max(b) from t2)
```
A subquery could be uncorrelated or correlated, it could be scalar subquery
(returns single row and single column) or not (returns multiple rows, for
EXISTS or IN).
A correlated subquery or uncorrelated subquery that returns multiple rows
will be rewritten as JOIN. Scalar subquery will be executed separately, result
will be filled into the expression (not finished yet).
LIMIT: A subquery inside a OR expression is not supported right now.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/davies/spark parse_subquery
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/10706.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #10706
----
commit dfe501a087b4292f7327ad04bb0742eeedffab9f
Author: Davies Liu <[email protected]>
Date: 2016-01-10T08:57:12Z
parse subquery
commit b855816c6bab14d0166f6d2f9d19044c194a1f96
Author: Davies Liu <[email protected]>
Date: 2016-01-10T09:36:04Z
add left anti join
commit 9918c0cc14077e803ec73a42c75a62bb0383e456
Author: Davies Liu <[email protected]>
Date: 2016-01-10T23:56:36Z
support exists / not exists
commit 37f22e2f145dc48ae71c8bf022973abc9538a8fe
Author: Davies Liu <[email protected]>
Date: 2016-01-11T06:28:06Z
support in subquery
commit fde2461a159c89569269b7dc6a2f1bcbd5a9ec70
Author: Davies Liu <[email protected]>
Date: 2016-01-11T08:04:04Z
support correlated scalar subquery
----
---
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]