You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/27 13:29:14 UTC

[GitHub] [arrow-datafusion] andygrove opened a new pull request, #2354: Add SQL query planner support for Scalar Subqueries

andygrove opened a new pull request, #2354:
URL: https://github.com/apache/arrow-datafusion/pull/2354

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Follows on from https://github.com/apache/arrow-datafusion/pull/2352.
   
   Closes https://github.com/apache/arrow-datafusion/issues/2353
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   Add SQL query planner support for Scalar Subqueries
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Add SQL query planner support for Scalar Subqueries
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   Add SQL query planner support for Scalar Subqueries
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] andygrove merged pull request #2354: Add SQL query planner support for Scalar Subqueries

Posted by GitBox <gi...@apache.org>.
andygrove merged PR #2354:
URL: https://github.com/apache/arrow-datafusion/pull/2354


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] andygrove commented on a diff in pull request #2354: Add SQL query planner support for Scalar Subqueries

Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #2354:
URL: https://github.com/apache/arrow-datafusion/pull/2354#discussion_r860206259


##########
datafusion/core/src/sql/planner.rs:
##########
@@ -1913,6 +1911,16 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         })
     }
 
+    fn parse_scalar_subquery(
+        &self,
+        subquery: &Query,
+        input_schema: &DFSchema,
+    ) -> Result<Expr> {
+        Ok(Expr::ScalarSubquery(Subquery {
+            subquery: Arc::new(self.subquery_to_plan(subquery.clone(), input_schema)?),

Review Comment:
   I filed https://github.com/apache/arrow-datafusion/issues/2361 to track the validation work



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] andygrove commented on a diff in pull request #2354: Add SQL query planner support for Scalar Subqueries

Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #2354:
URL: https://github.com/apache/arrow-datafusion/pull/2354#discussion_r860191346


##########
datafusion/core/src/sql/planner.rs:
##########
@@ -1913,6 +1911,16 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         })
     }
 
+    fn parse_scalar_subquery(
+        &self,
+        subquery: &Query,
+        input_schema: &DFSchema,
+    ) -> Result<Expr> {
+        Ok(Expr::ScalarSubquery(Subquery {
+            subquery: Arc::new(self.subquery_to_plan(subquery.clone(), input_schema)?),

Review Comment:
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2354: Add SQL query planner support for Scalar Subqueries

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2354:
URL: https://github.com/apache/arrow-datafusion/pull/2354#discussion_r860185643


##########
datafusion/core/src/sql/planner.rs:
##########
@@ -1913,6 +1911,16 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         })
     }
 
+    fn parse_scalar_subquery(
+        &self,
+        subquery: &Query,
+        input_schema: &DFSchema,
+    ) -> Result<Expr> {
+        Ok(Expr::ScalarSubquery(Subquery {
+            subquery: Arc::new(self.subquery_to_plan(subquery.clone(), input_schema)?),

Review Comment:
   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"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org