hvnsweeting opened a new issue, #688:
URL: https://github.com/apache/avro-rs/issues/688

   Similar to #680, tested at fd052bd7306478e60fc754a8a8955a3d2a5e28ac 
   
   ```rs
       #[test]
       fn test_round_trip_decimal_fixed_length_zero() -> TestResult {
           use crate::reader::datum::GenericDatumReader;
           use crate::writer::datum::GenericDatumWriter;
   
           let schema = Schema::parse_str(
               r#"{"type": "fixed", "logicalType": "decimal", "size": 0, 
"name": "account", "precision": 1}"#,
           )?;
   
           let writer = GenericDatumWriter::builder(&schema).build().unwrap();
           let encoded = writer
               .write_value_to_vec(Value::Fixed(0, Vec::new()))
               .unwrap();
           assert!(&encoded.is_empty());
   
           let reader = GenericDatumReader::builder(&schema).build().unwrap();
           reader.read_value(&mut &encoded[..]).unwrap();
   
           Ok(())
       }
   ```
   
   Output
   ```
   thread 'decode::tests::test_round_trip_decimal_fixed_length_zero' (184653) 
panicked at avro/src/decode.rs:1202:46:
   called `Result::unwrap()` on an `Err` value: Error { details: Decimal bytes 
cannot be zero length }
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   test decode::tests::test_round_trip_decimal_fixed_length_zero ... FAILED
   ```
   
   Java logs a warning "Ignoring invalid logical type for name: decimal", then 
treats the value as fixed (not logical Decimal), then successfully 
encode/decode.
   
   As [spec](https://avro.apache.org/docs/1.12.0/specification/#logical-types):
   > If a logical type is invalid, for example a decimal with scale greater 
than its precision, then implementations should ignore the logical type and use 
the underlying Avro type.
   


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