You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "neilconway (via GitHub)" <gi...@apache.org> on 2026/08/26 15:23:59 UTC

[I] Parquet writer produces wrong min/max statistics for `BYTE_ARRAY` `DECIMAL` columns [arrow-rs]

neilconway opened a new issue, #10860:
URL: https://github.com/apache/arrow-rs/issues/10860

   ### Describe the bug
   
   When a BYTE_ARRAY DECIMAL column contains values whose encodings have different byte lengths, the written row-group/page statistics can be wrong; see repro for example (min/max swapped).
   
   ### To Reproduce
   
   ```rust
   use parquet::basic::{ConvertedType, Repetition, Type as PhysicalType};
   use parquet::data_type::{ByteArray, ByteArrayType};
   use parquet::file::properties::WriterProperties;
   use parquet::file::reader::FileReader;
   use parquet::file::serialized_reader::SerializedFileReader;
   use parquet::file::writer::SerializedFileWriter;
   use parquet::schema::types::Type;
   use std::fs::File;
   use std::sync::Arc;
   
   let field = Type::primitive_type_builder("c", PhysicalType::BYTE_ARRAY)
       .with_repetition(Repetition::REQUIRED)
       .with_converted_type(ConvertedType::DECIMAL)
       .with_precision(8)
       .with_scale(0)
       .build()
       .unwrap();
   let schema = Arc::new(
       Type::group_type_builder("schema")
           .with_fields(vec![Arc::new(field)])
           .build()
           .unwrap(),
   );
   
   let file = File::create("/tmp/repro.parquet").unwrap();
   let mut writer =
       SerializedFileWriter::new(file, schema, Arc::new(WriterProperties::builder().build())).unwrap();
   let mut rg = writer.next_row_group().unwrap();
   let mut col = rg.next_column().unwrap().unwrap();
   // minimal big-endian two's-complement: 255 and 32768
   let values = vec![
       ByteArray::from(vec![0x00u8, 0xFF]),       // 255
       ByteArray::from(vec![0x00u8, 0x80, 0x00]), // 32768
   ];
   col.typed::<ByteArrayType>().write_batch(&values, None, None).unwrap();
   col.close().unwrap();
   rg.close().unwrap();
   writer.close().unwrap();
   
   let reader = SerializedFileReader::new(File::open("/tmp/repro.parquet").unwrap()).unwrap();
   let stats = reader.metadata().row_group(0).column(0).statistics().unwrap();
   println!("{stats:?}");
   // min: Some(b"\0\x80\0") (= 32768), max: Some(b"\0\xff") (= 255),
   // max_value_exact: true, min_value_exact: true
   // expected: min = 255, max = 32768
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
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.apache.org

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


Re: [I] Parquet writer produces wrong min/max statistics for `BYTE_ARRAY` `DECIMAL` columns [arrow-rs]

Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway commented on issue #10860:
URL: https://github.com/apache/arrow-rs/issues/10860#issuecomment-5427599037

   take


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


Re: [I] Parquet writer produces wrong min/max statistics for `BYTE_ARRAY` `DECIMAL` columns [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #10860: Parquet writer produces wrong min/max statistics for `BYTE_ARRAY` `DECIMAL` columns
URL: https://github.com/apache/arrow-rs/issues/10860


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