You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/12/26 21:22:10 UTC
[arrow-datafusion] branch master updated: Create writer with `arrow::ipc::IPCWriteOptions` (#4730)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new 9331ee36b Create writer with `arrow::ipc::IPCWriteOptions` (#4730)
9331ee36b is described below
commit 9331ee36b27012c265b52a8a9593c79174a2bb34
Author: askoa <11...@users.noreply.github.com>
AuthorDate: Mon Dec 26 16:22:05 2022 -0500
Create writer with `arrow::ipc::IPCWriteOptions` (#4730)
* Create writer with `arrow::ipc::IPCWriteOptions`
* clippy fix
Co-authored-by: askoa <as...@local>
---
datafusion/core/src/physical_plan/common.rs | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/datafusion/core/src/physical_plan/common.rs b/datafusion/core/src/physical_plan/common.rs
index 1c36014f2..3cdc268cb 100644
--- a/datafusion/core/src/physical_plan/common.rs
+++ b/datafusion/core/src/physical_plan/common.rs
@@ -25,7 +25,7 @@ use crate::physical_plan::{displayable, ColumnStatistics, ExecutionPlan, Statist
use arrow::datatypes::{Schema, SchemaRef};
use arrow::error::ArrowError;
use arrow::error::Result as ArrowResult;
-use arrow::ipc::writer::FileWriter;
+use arrow::ipc::writer::{FileWriter, IpcWriteOptions};
use arrow::record_batch::RecordBatch;
use futures::{Future, Stream, StreamExt, TryStreamExt};
use log::debug;
@@ -391,6 +391,26 @@ impl IPCWriter {
})
}
+ /// Create new writer with IPC write options
+ pub fn new_with_options(
+ path: &Path,
+ schema: &Schema,
+ write_options: IpcWriteOptions,
+ ) -> Result<Self> {
+ let file = File::create(path).map_err(|e| {
+ DataFusionError::Execution(format!(
+ "Failed to create partition file at {:?}: {:?}",
+ path, e
+ ))
+ })?;
+ Ok(Self {
+ num_batches: 0,
+ num_rows: 0,
+ num_bytes: 0,
+ path: path.into(),
+ writer: FileWriter::try_new_with_options(file, schema, write_options)?,
+ })
+ }
/// Write one single batch
pub fn write(&mut self, batch: &RecordBatch) -> Result<()> {
self.writer.write(batch)?;