Skip to content

Conversation

@andygrove
Copy link
Member

@andygrove andygrove commented Apr 27, 2022

Which issue does this PR close?

Closes #2353

Rationale for this change

Add SQL query planner support for Scalar Subqueries

What changes are included in this PR?

Add SQL query planner support for Scalar Subqueries

Are there any user-facing changes?

Add SQL query planner support for Scalar Subqueries

@andygrove andygrove marked this pull request as ready for review April 27, 2022 13:31
@andygrove andygrove force-pushed the sql-planner-scalar-subquery branch from c82e410 to d082305 Compare April 27, 2022 13:32
input_schema: &DFSchema,
) -> Result<Expr> {
Ok(Expr::ScalarSubquery(Subquery {
subquery: Arc::new(self.subquery_to_plan(subquery.clone(), input_schema)?),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the scalar subquery must produce a single row typically otherwise it is a runtime error

Do you have thoughts about in what stage a query like the following would throw an error?

"SELECT p.id, (SELECT id FROM person) FROM person p"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that an optimizer rule should perform this type of validation check and this would cover both the SQL and DataFrame API (and maybe substrait one day) use cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed #2361 to track the validation work

@andygrove andygrove merged commit e596236 into apache:master Apr 27, 2022
@andygrove andygrove deleted the sql-planner-scalar-subquery branch April 27, 2022 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SQL query planner support for scalar subqueries

2 participants