From 1549afa1fb133adb25fb1698c769b447a476342e Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies Date: Tue, 23 Aug 2022 12:08:33 +0100 Subject: [PATCH] Don't panic on RleValueEncoder::flush_buffer if empty (#2558) --- parquet/src/arrow/arrow_reader/mod.rs | 4 ++++ parquet/src/encodings/encoding/mod.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/parquet/src/arrow/arrow_reader/mod.rs b/parquet/src/arrow/arrow_reader/mod.rs index 347c38cb3582..e7d9863ae6e1 100644 --- a/parquet/src/arrow/arrow_reader/mod.rs +++ b/parquet/src/arrow/arrow_reader/mod.rs @@ -1355,6 +1355,10 @@ mod tests { TestOptions::new(2, 256, 91) .with_null_percent(25) .with_enabled_statistics(EnabledStatistics::None), + // Test with all null + TestOptions::new(2, 128, 91) + .with_null_percent(100) + .with_enabled_statistics(EnabledStatistics::None), // Test skip // choose record_batch_batch (15) so batches cross row diff --git a/parquet/src/encodings/encoding/mod.rs b/parquet/src/encodings/encoding/mod.rs index 5d833da7d89e..34d3bb3d4c75 100644 --- a/parquet/src/encodings/encoding/mod.rs +++ b/parquet/src/encodings/encoding/mod.rs @@ -232,7 +232,7 @@ impl Encoder for RleValueEncoder { // Flush all encoder buffers and raw values let mut buf = rle_encoder.consume(); - assert!(buf.len() > 4, "should have had padding inserted"); + assert!(buf.len() >= 4, "should have had padding inserted"); // Note that buf does not have any offset, all data is encoded bytes let len = (buf.len() - 4) as i32;