alambov-md opened a new issue, #440:
URL: https://github.com/apache/avro-rs/issues/440

   Hello team!
   
   Apache Avro Specification states that:
   
   > A `uuid` logical type annotates an Avro `string` or `fixed` of length 16.
   
   However, in the current mainline (#6218cd7) schema requirements for 
underlying type are ignored on uuids serialisation, and the type depends on 
`apache_avro::util::set_serde_human_readable()` parameter: when `true` uuids 
are serialised into strings, when `false` - into bytes.
   This behaviour differs from latest released version `rel/release-0.21.0`, 
where the type depends on the schema.
   
   It seems the behaviour from `rel/release-0.21.0` is more correct. Could it 
be restored?
   
   Attaching here an integration test for convenience.
   ```rust
   use apache_avro::{Reader, Schema, Uuid, Writer};
   use std::error::Error;
   
   #[test]
   fn test_uuid_serliazation_deserialization() -> Result<(), Box<dyn Error>> {
       // This line makes the test to pass.
       // Currently it's passigng only with `set_serde_human_readable(true)`
       // It worked correctly both with `true` an `false in 
`rel/release-0.21.0`.
       // apache_avro::util::set_serde_human_readable(false);
   
       let raw_schema = r#" 
       {
           "name": "uuid",
           "type": "string",
           "logicalType": "uuid"
       }
       "#;
   
       let schema = Schema::parse_str(raw_schema)?;
       let initial_id = 
Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
   
       let mut writer = Writer::new(&schema, Vec::new())?;
       writer.append_ser(&initial_id)?;
   
       let input = writer.into_inner()?;
       let reader = Reader::with_schema(&schema, &input[..])?;
       
       for value in reader {
           println!("{value:?}");
           assert_eq!(initial_id, apache_avro::from_value::<Uuid>(&value?)?);
       }
   
       Ok(())
   }
   ```


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