Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SQL query planner support for Scalar Subqueries #2354

Merged
merged 2 commits into from
Apr 27, 2022

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

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Apr 27, 2022
@andygrove andygrove marked this pull request as ready for review April 27, 2022 13:31
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
datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SQL query planner support for scalar subqueries
2 participants