[ https://issues.apache.org/jira/browse/AVRO-3631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17867011#comment-17867011 ]
ASF subversion and git services commented on AVRO-3631: ------------------------------------------------------- Commit 34bc5587070152a97cf28cb6ebe4cd5c0b11ecc3 in avro's branch refs/heads/branch-1.11 from Romain Leroux [ https://gitbox.apache.org/repos/asf?p=avro.git;h=34bc55870 ] AVRO-3631: [Rust] More efficient (de)serialization using serde_bytes (#3027) * AVRO-3631: [Rust] More efficient (de)serialization using serde_bytes * AVRO-3631: [Rust] Bump MSRV to 1.73.0 * Remove env var that is default since Rust 1.70.0 --------- Co-authored-by: Martin Grigorov <marti...@users.noreply.github.com> (cherry picked from commit 17e7994bf0bd63938e7d3cb0f25ffbd2d51424b0) > Fix serialization of structs containing Fixed fields > ---------------------------------------------------- > > Key: AVRO-3631 > URL: https://issues.apache.org/jira/browse/AVRO-3631 > Project: Apache Avro > Issue Type: Bug > Components: rust > Reporter: Rik Heijdens > Priority: Major > Labels: pull-request-available > Time Spent: 6h > Remaining Estimate: 0h > > Consider the following minimal Avro Schema: > {noformat} > { > "type": "record", > "name": "TestStructFixedField", > "fields": [ > { > "name": "field", > "type": { > "name": "field", > "type": "fixed", > "size": 6 > } > } > ] > } > {noformat} > In Rust, I might represent this schema with the following struct: > {noformat} > #[derive(Debug, Serialize, Deserialize)] > struct TestStructFixedField { > field: [u8; 6] > } > {noformat} > I would then expect to be able to use `apache_avro::to_avro_datum()` to > convert an instance of `TestStructFixedField` into an `Vec<u8>` using an > instance of `Schema` initialized from the schema listed above. > However, this fails because the `Value` produced by `apache_avro::to_value()` > represents `field` as an `Value::Array<Value::Int>` rather than a > `Value::Fixed<6, Vec<u8>` which does not pass schema validation. > I believe that there are two options to fix this: > 1. Allow Value::Array<Vec<Value::Int>> to pass validation if the array has > the expected length, and none of the contents of the array are out-of-range > for u8. If we go down this route, the implementation of `to_avro_datum()` > will have to take care of converting Value::Int to u8 when converting into > bytes. > 2. Update `apache_avro::to_value()` such that fixed length arrays are > converted into `Value::Fixed<N, Vec<u8>>` rather than `Value::Array`. -- This message was sent by Atlassian Jira (v8.20.10#820010)