GitHub user ravipesala opened a pull request:
https://github.com/apache/spark/pull/3249
[SPARK-4226][SQL] SparkSQL - Add support for subqueries in predicates('in'
clause)
This PR supports subqueries in preicates 'in' clause. The queries will be
transformed to the LeftSemi join as mentioned below.
Case 1 Uncorelated queries
-- original query
select C
from R1
where R1.A in (Select B from R2)
-- rewritten query
Select C
from R1 left semijoin R2 on R1.A = R2.B
Case 2 Corelated queries
-- original query
select C
from R1
where R1.A in (Select B from R2 where R1.X = R2.Y)
-- rewritten query
select C
from R1 left semi join
(select B, R2.Y as sq1_col0 from R2) sq1
on R1.X = sq1.sq1_col0 and R1.A = sq1.B
Restriction : Alias need to be used as we convert it into join queries.
Complete specification is available in
https://issues.apache.org/jira/secure/attachment/12614003/SubQuerySpec.pdf
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ravipesala/spark SPARK-4226
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/3249.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 #3249
----
commit b670862276d828d94ca5da94a22944e98f8aaa55
Author: ravipesala <[email protected]>
Date: 2014-11-13T18:02:12Z
Supporting subqueries inside where 'in' clause
commit ccaddcb8c3229ba039c74acb8172f97ca99ffba1
Author: ravipesala <[email protected]>
Date: 2014-11-13T18:03:29Z
Added new expression class
----
---
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]