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/02 06:42:19 UTC

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

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



##########
File path: datafusion/src/execution/context.rs
##########
@@ -795,6 +794,56 @@ 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 filename = format!("part-{}.arrow", i);
+                    let path = fs_path.join(&filename);
+                    let file = fs::File::create(path)?;
+                    let mut writer = match writer_properties {
+                        Some(props) => FileWriter::try_new_with_options(

Review comment:
       just to confirm - you would then add the `IpcWriteOptions` as a new parameter to `try_new`, right?




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