tustvold commented on code in PR #2191:
URL: https://github.com/apache/arrow-rs/pull/2191#discussion_r930956328
##########
parquet/src/column/writer/mod.rs:
##########
@@ -1639,6 +1642,56 @@ mod tests {
assert!(page_statistics.distinct_count().is_none());
}
+ #[test]
+ fn test_disabled_statistics() {
+ let mut buf = Vec::with_capacity(100);
+ let mut write = TrackedWrite::new(&mut buf);
+ let page_writer = Box::new(SerializedPageWriter::new(&mut write));
+ let props = WriterProperties::builder()
+ .set_statistics_enabled(EnabledStatistics::None)
+ .set_writer_version(WriterVersion::PARQUET_2_0)
+ .build();
+ let props = Arc::new(props);
+
+ let mut writer = get_test_column_writer::<Int32Type>(page_writer, 1,
0, props);
+ writer
+ .write_batch(&[1, 2, 3, 4], Some(&[1, 0, 0, 1, 1, 1]), None)
+ .unwrap();
+
+ let (_, _, metadata, _, _) = writer.close().unwrap();
+ assert!(metadata.statistics().is_none());
+
+ let reader = SerializedPageReader::new(
+ std::io::Cursor::new(buf),
+ 6,
+ Compression::UNCOMPRESSED,
+ Type::INT32,
+ )
+ .unwrap();
+
+ let pages = reader.collect::<Result<Vec<_>>>().unwrap();
+ assert_eq!(pages.len(), 2);
+
+ assert_eq!(pages[0].page_type(), PageType::DICTIONARY_PAGE);
+ assert_eq!(pages[1].page_type(), PageType::DATA_PAGE_V2);
+
+ match &pages[1] {
+ Page::DataPageV2 {
+ num_values,
+ num_nulls,
+ num_rows,
+ statistics,
+ ..
+ } => {
+ assert_eq!(*num_values, 6);
Review Comment:
Confusingly in parquet num_values includes nulls, despite null values not
actually be encoded :laughing:
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]