You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "comphead (via GitHub)" <gi...@apache.org> on 2023/10/31 16:43:15 UTC

[PR] Minor: add `ExecutionPlan.execute()` snippet for sync methods [arrow-datafusion]

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

   ## 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 #.
   
   ## Rationale for this change
   Very often the question arises on debugging or using record stream in sync context. Adding a code snippet for `ExecutionPlan.execute()`
   <!--
    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?
   A code snippet
   <!--
   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.
   -->
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## 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


Re: [PR] Minor: add `ExecutionPlan.execute()` snippet for sync methods [arrow-datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #8010:
URL: https://github.com/apache/arrow-datafusion/pull/8010#issuecomment-1788076852

   Closed in favor of #8013 


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


Re: [PR] Minor: add `ExecutionPlan.execute()` snippet for sync methods [arrow-datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #8010:
URL: https://github.com/apache/arrow-datafusion/pull/8010#discussion_r1377918012


##########
datafusion/physical-plan/src/lib.rs:
##########
@@ -235,7 +235,28 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
         Ok(None)
     }
 
-    /// Begin execution of `partition`, returning a stream of [`RecordBatch`]es.
+    /// Start plan execution for `partition`, returning a [`SendableRecordBatchStream`] of [`RecordBatch`]es.
+    ///
+    ///
+    /// Often its needed to call [`.await`](https://doc.rust-lang.org/std/keyword.await.html) just after the stream async combinators.
+    /// To call it within the sync method please refer the snippet below. The snippet can also be used to help output/debug the node execution on batch level
+    ///
+    /// ```no_run
+    /// use datafusion_common::DataFusionError;
+    ///
+    /// fn print_plan_exec() -> Result<(), DataFusionError> {
+    ///     let stream = node.execute(0, task_ctx)?;
+    ///     futures::stream::once(async move {

Review Comment:
   okay, I'll include another use case with amending stream and returning it back to the user. Like in https://github.com/apache/arrow-datafusion/blob/main/datafusion/physical-plan/src/sorts/sort.rs#L895
   
   @tustvold I believe you mean exactly that?
   



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


Re: [PR] Minor: add `ExecutionPlan.execute()` snippet for sync methods [arrow-datafusion]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #8010:
URL: https://github.com/apache/arrow-datafusion/pull/8010#issuecomment-1787747728

   I tried to encode what I was expecting in https://github.com/apache/arrow-datafusion/pull/8013 PTAL


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


Re: [PR] Minor: add `ExecutionPlan.execute()` snippet for sync methods [arrow-datafusion]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #8010:
URL: https://github.com/apache/arrow-datafusion/pull/8010#discussion_r1377908654


##########
datafusion/physical-plan/src/lib.rs:
##########
@@ -235,7 +235,28 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
         Ok(None)
     }
 
-    /// Begin execution of `partition`, returning a stream of [`RecordBatch`]es.
+    /// Start plan execution for `partition`, returning a [`SendableRecordBatchStream`] of [`RecordBatch`]es.
+    ///
+    ///
+    /// Often its needed to call [`.await`](https://doc.rust-lang.org/std/keyword.await.html) just after the stream async combinators.
+    /// To call it within the sync method please refer the snippet below. The snippet can also be used to help output/debug the node execution on batch level
+    ///
+    /// ```no_run
+    /// use datafusion_common::DataFusionError;
+    ///
+    /// fn print_plan_exec() -> Result<(), DataFusionError> {
+    ///     let stream = node.execute(0, task_ctx)?;
+    ///     futures::stream::once(async move {

Review Comment:
   This stream gets immediately dropped and therefore will never run?



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


Re: [PR] Minor: add `ExecutionPlan.execute()` snippet for sync methods [arrow-datafusion]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #8010:
URL: https://github.com/apache/arrow-datafusion/pull/8010#discussion_r1377920792


##########
datafusion/physical-plan/src/lib.rs:
##########
@@ -235,7 +235,28 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
         Ok(None)
     }
 
-    /// Begin execution of `partition`, returning a stream of [`RecordBatch`]es.
+    /// Start plan execution for `partition`, returning a [`SendableRecordBatchStream`] of [`RecordBatch`]es.
+    ///
+    ///
+    /// Often its needed to call [`.await`](https://doc.rust-lang.org/std/keyword.await.html) just after the stream async combinators.
+    /// To call it within the sync method please refer the snippet below. The snippet can also be used to help output/debug the node execution on batch level
+    ///
+    /// ```no_run
+    /// use datafusion_common::DataFusionError;
+    ///
+    /// fn print_plan_exec() -> Result<(), DataFusionError> {
+    ///     let stream = node.execute(0, task_ctx)?;
+    ///     futures::stream::once(async move {

Review Comment:
   I mean as written this example doesn't do anything and is therefore just misleading.
   
   > Like in https://github.com/apache/arrow-datafusion/blob/main/datafusion/physical-plan/src/sorts/sort.rs#L895
   
   Yes, that is I think a good example of the pattern



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


Re: [PR] Minor: add `ExecutionPlan.execute()` snippet for sync methods [arrow-datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead closed pull request #8010: Minor: add `ExecutionPlan.execute()` snippet for sync methods
URL: https://github.com/apache/arrow-datafusion/pull/8010


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