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/05/02 08:23:58 UTC

[GitHub] [arrow-datafusion] comphead opened a new pull request, #2402: nested query fix

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

   # 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.
   -->
   
   Closes #2381.
   
    # 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.  
   -->
   
   
   # 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.
   -->
   Fix bug with nested queries panicked because of NotImplemented
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   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 commented on a diff in pull request #2402: nested query fix

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


##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -1127,3 +1129,25 @@ async fn csv_query_sqrt_sqrt() -> Result<()> {
     assert_float_eq(&expected, &actual);
     Ok(())
 }
+
+#[tokio::test]
+async fn nested_subquery() -> Result<()> {
+    let ctx = SessionContext::new();
+    let schema = Schema::new(vec![
+        Field::new("id", DataType::Int16, false),
+        Field::new("a", DataType::Int16, false),
+    ]);
+    let empty_table = Arc::new(EmptyTable::new(Arc::new(schema)));
+    ctx.register_table("t1", empty_table.clone())?;
+    ctx.register_table("t2", empty_table)?;
+    let sql = "SELECT COUNT(*) as cnt \
+    FROM (\
+        (SELECT id FROM t1) EXCEPT \
+        (SELECT id FROM t2)\
+        ) foo";
+    let actual = execute_to_batches(&ctx, sql).await;
+    // the purpose of this test is just to make sure the query produces a valid plan

Review Comment:
   I think this comment can be removed since the test actually is executing and producing the correct result?



-- 
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 #2402: nested query fix

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


##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -1127,3 +1129,25 @@ async fn csv_query_sqrt_sqrt() -> Result<()> {
     assert_float_eq(&expected, &actual);
     Ok(())
 }
+
+#[tokio::test]
+async fn nested_subquery() -> Result<()> {
+    let ctx = SessionContext::new();
+    let schema = Schema::new(vec![
+        Field::new("id", DataType::Int16, false),
+        Field::new("a", DataType::Int16, false),
+    ]);
+    let empty_table = Arc::new(EmptyTable::new(Arc::new(schema)));
+    ctx.register_table("t1", empty_table.clone())?;
+    ctx.register_table("t2", empty_table)?;
+    let sql = "SELECT COUNT(*) as cnt \
+    FROM (\
+        (SELECT id FROM t1) EXCEPT \
+        (SELECT id FROM t2)\
+        ) foo";
+    let actual = execute_to_batches(&ctx, sql).await;
+    // the purpose of this test is just to make sure the query produces a valid plan
+    let expected = vec!["+-----+", "| cnt |", "+-----+", "| 0   |", "+-----+"];

Review Comment:
   I'm going to go ahead and merge this. Perhaps we can improve the test formatting as a separate PR.



-- 
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 #2402: nested query fix

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


-- 
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 #2402: nested query fix

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


##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -1127,3 +1129,25 @@ async fn csv_query_sqrt_sqrt() -> Result<()> {
     assert_float_eq(&expected, &actual);
     Ok(())
 }
+
+#[tokio::test]
+async fn nested_subquery() -> Result<()> {
+    let ctx = SessionContext::new();
+    let schema = Schema::new(vec![
+        Field::new("id", DataType::Int16, false),
+        Field::new("a", DataType::Int16, false),
+    ]);
+    let empty_table = Arc::new(EmptyTable::new(Arc::new(schema)));
+    ctx.register_table("t1", empty_table.clone())?;
+    ctx.register_table("t2", empty_table)?;
+    let sql = "SELECT COUNT(*) as cnt \
+    FROM (\
+        (SELECT id FROM t1) EXCEPT \
+        (SELECT id FROM t2)\
+        ) foo";
+    let actual = execute_to_batches(&ctx, sql).await;
+    // the purpose of this test is just to make sure the query produces a valid plan
+    let expected = vec!["+-----+", "| cnt |", "+-----+", "| 0   |", "+-----+"];

Review Comment:
   Could you disable rustfmt for this line and format it so that it is easier to read, as shown in https://github.com/apache/arrow-datafusion/pull/2413



-- 
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 #2402: nested query fix

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


##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -1127,3 +1129,25 @@ async fn csv_query_sqrt_sqrt() -> Result<()> {
     assert_float_eq(&expected, &actual);
     Ok(())
 }
+
+#[tokio::test]
+async fn nested_subquery() -> Result<()> {
+    let ctx = SessionContext::new();
+    let schema = Schema::new(vec![
+        Field::new("id", DataType::Int16, false),
+        Field::new("a", DataType::Int16, false),
+    ]);
+    let empty_table = Arc::new(EmptyTable::new(Arc::new(schema)));
+    ctx.register_table("t1", empty_table.clone())?;
+    ctx.register_table("t2", empty_table)?;
+    let sql = "SELECT COUNT(*) as cnt \
+    FROM (\
+        (SELECT id FROM t1) EXCEPT \
+        (SELECT id FROM t2)\
+        ) foo";
+    let actual = execute_to_batches(&ctx, sql).await;
+    // the purpose of this test is just to make sure the query produces a valid plan

Review Comment:
   Actually, I suppose the comment is valid because we are executing against an empty batch.



-- 
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