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-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new c2d2311020 Do not print compression level in schema printer (#6271)
c2d2311020 is described below

commit c2d23110205087febf6edbf166fd31090e08aafe
Author: Thomas ten Cate <[email protected]>
AuthorDate: Tue Aug 20 15:30:44 2024 +0200

    Do not print compression level in schema printer (#6271)
    
    The compression level is only used during compression, not
    decompression, and isn't actually stored in the metadata. Printing it is
    misleading.
---
 parquet/src/basic.rs          | 17 +++++++++++++++++
 parquet/src/schema/printer.rs |  6 +++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/parquet/src/basic.rs b/parquet/src/basic.rs
index a12c9d8608..02c2f44f60 100644
--- a/parquet/src/basic.rs
+++ b/parquet/src/basic.rs
@@ -358,6 +358,14 @@ pub enum Compression {
     LZ4_RAW,
 }
 
+impl Compression {
+    /// Returns the codec type of this compression setting as a string, 
without the compression
+    /// level.
+    pub(crate) fn codec_to_string(self) -> String {
+        format!("{:?}", self).split('(').next().unwrap().to_owned()
+    }
+}
+
 fn split_compression_string(str_setting: &str) -> Result<(&str, Option<u32>), 
ParquetError> {
     let split_setting = str_setting.split_once('(');
 
@@ -1915,6 +1923,15 @@ mod tests {
         );
     }
 
+    #[test]
+    fn test_compression_codec_to_string() {
+        assert_eq!(Compression::UNCOMPRESSED.codec_to_string(), 
"UNCOMPRESSED");
+        assert_eq!(
+            Compression::ZSTD(ZstdLevel::default()).codec_to_string(),
+            "ZSTD"
+        );
+    }
+
     #[test]
     fn test_display_compression() {
         assert_eq!(Compression::UNCOMPRESSED.to_string(), "UNCOMPRESSED");
diff --git a/parquet/src/schema/printer.rs b/parquet/src/schema/printer.rs
index 0bbf2af748..32d727427e 100644
--- a/parquet/src/schema/printer.rs
+++ b/parquet/src/schema/printer.rs
@@ -130,7 +130,11 @@ fn print_column_chunk_metadata(out: &mut dyn io::Write, 
cc_metadata: &ColumnChun
     writeln!(out, "file path: {file_path_str}");
     writeln!(out, "file offset: {}", cc_metadata.file_offset());
     writeln!(out, "num of values: {}", cc_metadata.num_values());
-    writeln!(out, "compression: {}", cc_metadata.compression());
+    writeln!(
+        out,
+        "compression: {}",
+        cc_metadata.compression().codec_to_string()
+    );
     writeln!(
         out,
         "total compressed size (in bytes): {}",

Reply via email to