This is an automated email from the ASF dual-hosted git repository.
Kriskras99 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 771363d fix: Strip the field `order` attribute from the Parsing
Canonical Form (#716)
771363d is described below
commit 771363dc8d5b57a113f89ba539109f43202968b7
Author: Wleeaf <[email protected]>
AuthorDate: Sun Oct 25 19:30:10 2026 +0300
fix: Strip the field `order` attribute from the Parsing Canonical Form
(#716)
The [STRIP] rule keeps only type, name, fields, symbols, items, values
and size. `order` was kept for record fields, so the canonical form and
fingerprint of such a schema differed from test vector 026 in the
specification's schema-tests.txt and from the Java and Python SDKs.
Co-authored-by: Wleeaf <[email protected]>
---
avro/src/schema/mod.rs | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/avro/src/schema/mod.rs b/avro/src/schema/mod.rs
index cf97bd5..0f4b129 100644
--- a/avro/src/schema/mod.rs
+++ b/avro/src/schema/mod.rs
@@ -1130,6 +1130,7 @@ fn pcf_map(schema: &Map<String, JsonValue>,
defined_names: &mut HashSet<String>)
|| k == "doc"
|| k == "aliases"
|| k == "logicalType"
+ || k == "order"
{
continue;
}
@@ -2207,6 +2208,32 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_canonical_form_strips_field_order() -> TestResult {
+ // Test vector 026 from the specification's
share/test/data/schema-tests.txt
+ let schema = Schema::parse_str(
+ r#"{
+ "fields": [
+ {"type": "boolean", "aliases": [], "name": "f1",
"default": true},
+ {"order": "descending", "name": "f2", "doc": "Hello",
"type": "int"}
+ ],
+ "type": "record",
+ "name": "foo"
+ }"#,
+ )?;
+ assert_eq!(
+ schema.canonical_form(),
+
r#"{"name":"foo","type":"record","fields":[{"name":"f1","type":"boolean"},{"name":"f2","type":"int"}]}"#
+ );
+ // -4860222112080293046 in schema-tests.txt, as little-endian bytes
+ assert_eq!(
+ format!("{}", schema.fingerprint::<Rabin>()),
+ "4a93f457bd058dbc"
+ );
+
+ Ok(())
+ }
+
#[test]
fn test_logical_types() -> TestResult {
let schema = Schema::parse_str(r#"{"type": "int", "logicalType":
"date"}"#)?;