marcosschroh commented on code in PR #2774:
URL: https://github.com/apache/avro/pull/2774#discussion_r1508934950
##########
lang/rust/avro/src/schema_compatibility.rs:
##########
@@ -394,70 +384,21 @@ impl SchemaCompatibility {
.then_some(())
.ok_or(CompatibilityError::FixedMismatch);
}
-
- return Err(CompatibilityError::TypeExpected {
- schema_type: String::from("writers_schema"),
- expected_type: vec![r_type],
- });
- }
- }
- SchemaKind::Enum => {
- if let Schema::Enum(EnumSchema { name: w_name, .. }) =
writers_schema {
- if let Schema::Enum(EnumSchema { name: r_name, .. }) =
readers_schema {
- if w_name.name == r_name.name {
- return Ok(());
- }
-
- return Err(CompatibilityError::NameMismatch {
- writer_name: w_name.name.clone(),
- reader_name: r_name.name.clone(),
- });
- }
-
- return Err(CompatibilityError::TypeExpected {
- schema_type: String::from("readers_schema"),
- expected_type: vec![r_type],
- });
}
-
- return Err(CompatibilityError::TypeExpected {
- schema_type: String::from("writers_schema"),
- expected_type: vec![r_type],
- });
}
SchemaKind::Map => {
if let Schema::Map(w_m) = writers_schema {
if let Schema::Map(r_m) = readers_schema {
return
SchemaCompatibility::match_schemas(&w_m.types, &r_m.types);
}
-
- return Err(CompatibilityError::TypeExpected {
- schema_type: String::from("readers_schema"),
- expected_type: vec![r_type],
- });
}
-
- return Err(CompatibilityError::TypeExpected {
Review Comment:
No because it only enters the first match when both types are the same [if
w_type == r_type
{...}](https://github.com/apache/avro/blob/b7d7a056a378511fd9f908531a5673ab0e16d13c/lang/rust/avro/src/schema_compatibility.rs#L346).
We always know for sure that the schema types are always the same when enter
the first match.
If the reader schema is `SchemaKind::IMap` and the writer is something else,
let's say `SchemaKind::Int` you will end up in the [second
match](https://github.com/apache/avro/blob/b7d7a056a378511fd9f908531a5673ab0e16d13c/lang/rust/avro/src/schema_compatibility.rs#L502)
to check the writer types.
I think it is a bit confusing the but little by little we can make it more
clear
--
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]