This is an automated email from the ASF dual-hosted git repository. mgrigorov pushed a commit to branch avro-3894-take-into-account-aliases in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/avro-3894-take-into-account-aliases by this push: new 4223b3551 AVRO-3894: [Rust] Add a unit test for schema_compatibility 4223b3551 is described below commit 4223b3551cee2dbb4ef376d2eedc4e9c1b59a0ab Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org> AuthorDate: Wed Oct 25 09:40:26 2023 +0300 AVRO-3894: [Rust] Add a unit test for schema_compatibility Provided-by: Josua Stingelin Signed-off-by: Martin Tzvetanov Grigorov <mgrigo...@apache.org> --- lang/rust/avro/src/schema_compatibility.rs | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lang/rust/avro/src/schema_compatibility.rs b/lang/rust/avro/src/schema_compatibility.rs index a15c18407..e7575b402 100644 --- a/lang/rust/avro/src/schema_compatibility.rs +++ b/lang/rust/avro/src/schema_compatibility.rs @@ -1038,4 +1038,49 @@ mod tests { Ok(()) } + + #[test] + fn avro_3894_take_aliases_into_account_when_serializing_for_schema_compatibility() -> TestResult + { + use serde::{Deserialize, Serialize}; + + const RAW_SCHEMA_V1: &str = r#" + { + "type": "record", + "name": "Conference", + "namespace": "advdaba", + "fields": [ + {"type": "string", "name": "name"}, + {"type": "long", "name": "date"} + ] + }"#; + const RAW_SCHEMA_V2: &str = r#" + { + "type": "record", + "name": "Conference", + "namespace": "advdaba", + "fields": [ + {"type": "string", "name": "name"}, + {"type": "long", "name": "date", "aliases" : [ "time" ]} + ] + }"#; + + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] + pub struct Conference { + pub name: String, + pub date: i64, + } + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] + pub struct ConferenceV2 { + pub name: String, + pub time: i64, + } + + let schema_v1 = Schema::parse_str(RAW_SCHEMA_V1)?; + let schema_v2 = Schema::parse_str(RAW_SCHEMA_V2)?; + + assert_eq!(true, SchemaCompatibility::can_read(&schema_v1, &schema_v2)); + + Ok(()) + } }