diff options
author | Davies Liu <davies@databricks.com> | 2016-02-20 21:01:51 -0800 |
---|---|---|
committer | Davies Liu <davies.liu@gmail.com> | 2016-02-20 21:01:51 -0800 |
commit | 7925071280bfa1570435bde3e93492eaf2167d56 (patch) | |
tree | 56a7500e75d53b58389351db098b220aa93cb036 /examples/src | |
parent | f88c641bc8afa836ae597801ae7520da90e8472a (diff) | |
download | spark-7925071280bfa1570435bde3e93492eaf2167d56.tar.gz spark-7925071280bfa1570435bde3e93492eaf2167d56.tar.bz2 spark-7925071280bfa1570435bde3e93492eaf2167d56.zip |
[SPARK-13306] [SQL] uncorrelated scalar subquery
A scalar subquery is a subquery that only generate single row and single column, could be used as part of expression. Uncorrelated scalar subquery means it does not has a reference to external table.
All the uncorrelated scalar subqueries will be executed during prepare() of SparkPlan.
The plans for query
```sql
select 1 + (select 2 + (select 3))
```
looks like this
```
== Parsed Logical Plan ==
'Project [unresolvedalias((1 + subquery#1),None)]
:- OneRowRelation$
+- 'Subquery subquery#1
+- 'Project [unresolvedalias((2 + subquery#0),None)]
:- OneRowRelation$
+- 'Subquery subquery#0
+- 'Project [unresolvedalias(3,None)]
+- OneRowRelation$
== Analyzed Logical Plan ==
_c0: int
Project [(1 + subquery#1) AS _c0#4]
:- OneRowRelation$
+- Subquery subquery#1
+- Project [(2 + subquery#0) AS _c0#3]
:- OneRowRelation$
+- Subquery subquery#0
+- Project [3 AS _c0#2]
+- OneRowRelation$
== Optimized Logical Plan ==
Project [(1 + subquery#1) AS _c0#4]
:- OneRowRelation$
+- Subquery subquery#1
+- Project [(2 + subquery#0) AS _c0#3]
:- OneRowRelation$
+- Subquery subquery#0
+- Project [3 AS _c0#2]
+- OneRowRelation$
== Physical Plan ==
WholeStageCodegen
: +- Project [(1 + subquery#1) AS _c0#4]
: :- INPUT
: +- Subquery subquery#1
: +- WholeStageCodegen
: : +- Project [(2 + subquery#0) AS _c0#3]
: : :- INPUT
: : +- Subquery subquery#0
: : +- WholeStageCodegen
: : : +- Project [3 AS _c0#2]
: : : +- INPUT
: : +- Scan OneRowRelation[]
: +- Scan OneRowRelation[]
+- Scan OneRowRelation[]
```
Author: Davies Liu <davies@databricks.com>
Closes #11190 from davies/scalar_subquery.
Diffstat (limited to 'examples/src')
0 files changed, 0 insertions, 0 deletions