alamb commented on code in PR #7283:
URL: https://github.com/apache/arrow-rs/pull/7283#discussion_r1996251793


##########
parquet/src/arrow/mod.rs:
##########
@@ -93,6 +93,55 @@
 //!
 //! println!("Read {} records.", record_batch.num_rows());
 //! ```
+//!
+//! # Example of reading non-uniformly encrypted parquet file into arrow 
record batch
+//!
+//! Note: This requires the experimental `encryption` feature to be enabled at 
compile time.
+//!
+//!
+#![cfg_attr(feature = "encryption", doc = "```rust")]
+#![cfg_attr(not(feature = "encryption"), doc = "```ignore")]
+//! # use arrow_array::{Int32Array, ArrayRef};
+//! # use arrow_array::{types, RecordBatch};
+//! # use parquet::arrow::arrow_reader::{
+//! #     ArrowReaderMetadata, ArrowReaderOptions, 
ParquetRecordBatchReaderBuilder,
+//! # };
+//! # use arrow_array::cast::AsArray;
+//! # use parquet::file::metadata::ParquetMetaData;
+//! # use tempfile::tempfile;
+//! # use std::fs::File;
+//! # use parquet::encryption::decrypt::FileDecryptionProperties;
+//! # let test_data = arrow::util::test_util::parquet_test_data();
+//! # let path = 
format!("{test_data}/encrypt_columns_and_footer.parquet.encrypted");
+//! #
+//! let file = File::open(path).unwrap();
+//!
+//! // Define the AES encryption keys required required for decrypting the 
footer metadata
+//! // and column-specific data. If only a footer key is used then it is 
assumed that the
+//! // file uses uniform encryption and all columns are encrypted with the 
footer key.
+//! // If any column keys are specified, other columns without a key provided 
are assumed
+//! // to be unencrypted
+//! let footer_key = "0123456789012345".as_bytes(); // Keys are 128 bits (16 
bytes)
+//! let column_1_key = "1234567890123450".as_bytes();
+//! let column_2_key = "1234567890123451".as_bytes();
+//!
+//! let decryption_properties = 
FileDecryptionProperties::builder(footer_key.to_vec())
+//!     .with_column_key("double_field", column_1_key.to_vec())
+//!     .with_column_key("float_field", column_2_key.to_vec())
+//!     .build()
+//!     .unwrap();
+//!
+//! let options =
+//!         
ArrowReaderOptions::default().with_file_decryption_properties(decryption_properties);
+//! let reader_metadata = ArrowReaderMetadata::load(&file, 
options.clone()).unwrap();
+//! let file_metadata = reader_metadata.metadata().file_metadata();
+//! println!("File has {} rows.", file_metadata.num_rows());

Review Comment:
   I think a more common pattern in rust crates is to use `assert_eq!` rather 
than println! -- it then contains the actual expected output in the example and 
is verified by the docs test



-- 
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-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to