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/03/01 14:58:16 UTC

[GitHub] [arrow-datafusion] alamb commented on a change in pull request #1893: Add write_ipc to ExecutionContext

alamb commented on a change in pull request #1893:
URL: https://github.com/apache/arrow-datafusion/pull/1893#discussion_r816846453



##########
File path: datafusion/src/execution/context.rs
##########
@@ -795,6 +796,57 @@ impl ExecutionContext {
         }
     }
 
+    /// Executes a query and writes the results to an Arrow IPC file.
+    pub async fn write_ipc(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        path: impl AsRef<str>,
+        writer_properties: Option<IpcWriteOptions>,
+    ) -> Result<()> {
+        let path = path.as_ref();
+        // create directory to contain the Parquet files (one per partition)
+        let fs_path = Path::new(path);
+        let runtime = self.runtime_env();
+        match fs::create_dir(fs_path) {
+            Ok(()) => {
+                let mut tasks = vec![];
+                for i in 0..plan.output_partitioning().partition_count() {
+                    let plan = plan.clone();
+                    let filename = format!("part-{}.parquet", i);

Review comment:
       probably needs to be named something other than `.parquet`

##########
File path: datafusion/src/execution/context.rs
##########
@@ -795,6 +796,57 @@ impl ExecutionContext {
         }
     }
 
+    /// Executes a query and writes the results to an Arrow IPC file.
+    pub async fn write_ipc(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        path: impl AsRef<str>,
+        writer_properties: Option<IpcWriteOptions>,
+    ) -> Result<()> {
+        let path = path.as_ref();
+        // create directory to contain the Parquet files (one per partition)
+        let fs_path = Path::new(path);
+        let runtime = self.runtime_env();
+        match fs::create_dir(fs_path) {
+            Ok(()) => {
+                let mut tasks = vec![];
+                for i in 0..plan.output_partitioning().partition_count() {
+                    let plan = plan.clone();

Review comment:
       why does the plan need to be cloned?




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