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 2021/09/21 18:17:22 UTC

[GitHub] [arrow-rs] Dandandan commented on a change in pull request #797: Add Parquet writer example to docs

Dandandan commented on a change in pull request #797:
URL: https://github.com/apache/arrow-rs/pull/797#discussion_r713301865



##########
File path: parquet/src/arrow/mod.rs
##########
@@ -48,6 +48,39 @@
 //!    }
 //!}
 //! ```
+//!# Example of writing Arrow record batch to Parquet file
+//!
+//!```rust, no_run
+//! use arrow::array::Int32Array;
+//! use arrow::datatypes::{DataType, Field, Schema};
+//! use arrow::record_batch::RecordBatch;
+//! use parquet::arrow::arrow_writer::ArrowWriter;
+//! use parquet::file::properties::WriterProperties;
+//! use std::fs::File;
+//! use std::sync::Arc;
+//! let ids = Int32Array::from(vec![1, 2, 3, 4]);
+//! let vals = Int32Array::from(vec![5, 6, 7, 8]);
+//! let schema = Arc::new(Schema::new(vec![
+//!     Field::new("id", DataType::Int32, false),
+//!     Field::new("val", DataType::Int32, false),
+//! ]));
+//!
+//! let file = File::create("data.parquet").unwrap();
+//!
+//! let batch =
+//!     RecordBatch::try_new(Arc::clone(&schema), vec![Arc::new(ids), Arc::new(vals)]).unwrap();
+//! let batches = vec![batch];
+//!
+//! let props = WriterProperties::builder().build();

Review comment:
       Maybe show changing some properties like setting compression to snappy or zstd?




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