You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "martin-g (via GitHub)" <gi...@apache.org> on 2023/12/11 14:12:07 UTC

Re: [PR] AVRO-3917: [Rust] take field aliases into account when calculating sc… [avro]

martin-g commented on code in PR #2633:
URL: https://github.com/apache/avro/pull/2633#discussion_r1422521191


##########
lang/rust/avro/src/schema_compatibility.rs:
##########
@@ -158,17 +158,45 @@ impl Checker {
             }) = readers_schema
             {
                 for field in r_fields.iter() {
-                    if let Some(pos) = w_lookup.get(&field.name) {
-                        if let Err(err) =
-                            self.full_match_schemas(&w_fields[*pos].schema, &field.schema)
-                        {
-                            return Err(CompatibilityError::FieldTypeMismatch(
-                                field.name.clone(),
-                                Box::new(err),
-                            ));
+                    // get all field names in a vector (field.name + aliases)
+                    let mut fields_names = vec![field.name.clone()];

Review Comment:
   I think you can use a `Vec<&str>` instead, and avoid the clones.



##########
lang/rust/avro/src/schema_compatibility.rs:
##########
@@ -1183,23 +1213,38 @@ mod tests {
                 {"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_v3 = Schema::parse_str(

Review Comment:
   Please create new test methods instead of extending existing ones.
   It is hard to follow what exactly is being tested when the test tests more than one use case.



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org