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

   ### Describe the bug
   
   The Parquet spec allows scale to be equal to precision.
   
   ### To Reproduce
   
   ```rust
   use parquet::basic::{ConvertedType, Repetition, Type as PhysicalType};
   use parquet::data_type::Int32Type;
   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;
   
   // message schema { required int32 c (DECIMAL(5, 5)); }
   let field = Type::primitive_type_builder("c", PhysicalType::INT32)
       .with_repetition(Repetition::REQUIRED)
       .with_converted_type(ConvertedType::DECIMAL)
       .with_precision(5)
       .with_scale(5)
       .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();
   col.typed::<Int32Type>().write_batch(&[12345], None, None).unwrap(); // 
0.12345
   col.close().unwrap();
   rg.close().unwrap();
   writer.close().unwrap();
   
   let reader = 
SerializedFileReader::new(File::open("/tmp/repro.parquet").unwrap()).unwrap();
   let row = reader.get_row_iter(None).unwrap().next().unwrap().unwrap();
   println!("{row}");
   // panics: assertion failed: decimal.scale() >= 0 && decimal.precision() > 
decimal.scale()
   // expected: {c: 0.12345}
   ```
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to