wleeaf opened a new pull request, #716:
URL: https://github.com/apache/avro-rs/pull/716
`Schema::canonical_form()` keeps a record field's `order` attribute, so the
canonical form and the fingerprints of such a schema differ from the
specification. Test vector 026 in apache/avro
`share/test/data/schema-tests.txt`:
```
<<INPUT
{ "fields":[{"type":"boolean", "aliases":[], "name":"f1", "default":true},
{"order":"descending","name":"f2","doc":"Hello","type":"int"}],
"type":"record", "name":"foo"
}
<<canonical
{"name":"foo","type":"record","fields":[{"name":"f1","type":"boolean"},{"name":"f2","type":"int"}]}
<<fingerprint -4860222112080293046
```
avro-rs currently produces
`...,{"name":"f2","type":"int","order":"descending"}]}`, with Rabin fingerprint
`e989409e0eb97e9b` instead of `4a93f457bd058dbc`. The Java
(`SchemaNormalization`) and Python SDKs both drop `order`, as the [STRIP] rule
asks: "Keep only attributes that are relevant to parsing data, which are: type,
name, fields, symbols, items, values, size."
`order` is in `RESERVED_FIELDS`, so the strip check in `pcf_map` let it
through. This adds it to the explicitly stripped keys, next to `default`,
`doc`, `aliases` and `logicalType`. It is the only one of the 34 vectors in
schema-tests.txt that avro-rs got wrong.
The test reproduces vector 026 and checks both the canonical form and the
Rabin fingerprint. It fails without the change and passes with it. `cargo fmt
--all --check`, `cargo clippy --all-features --all-targets --workspace` and
`cargo test --all-features` pass.
--
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]