woile commented on code in PR #2587:
URL: https://github.com/apache/avro/pull/2587#discussion_r1395612123
##########
lang/rust/avro/src/schema_compatibility.rs:
##########
@@ -133,38 +156,64 @@ impl Checker {
{
for field in r_fields.iter() {
if let Some(pos) = w_lookup.get(&field.name) {
- if !self.full_match_schemas(&w_fields[*pos].schema,
&field.schema) {
- return false;
+ if self
+ .full_match_schemas(&w_fields[*pos].schema,
&field.schema)
+ .is_err()
+ {
+ return
Err(Error::CompatibilityError(format!("Field {} in reader schema does not match
the type in the writer schema", field.name)));
}
} else if field.default.is_none() {
- return false;
+ return Err(Error::CompatibilityError(format!(
+ "Field {} in reader schema must have a default
value",
+ field.name
+ )));
}
}
}
}
- true
+ Ok(())
}
- fn match_union_schemas(&mut self, writers_schema: &Schema, readers_schema:
&Schema) -> bool {
+ fn match_union_schemas(
+ &mut self,
+ writers_schema: &Schema,
+ readers_schema: &Schema,
+ ) -> AvroResult<()> {
let w_type = SchemaKind::from(writers_schema);
let r_type = SchemaKind::from(readers_schema);
assert_eq!(r_type, SchemaKind::Union);
if w_type == SchemaKind::Union {
Review Comment:
maybe you could do this instead, to reduce the nesting
```rs
if w_type != SchemaKind::Union {
return Err(Error::CompatibilityError(String::from(
"readers_schema should have been Schema::Union",
)));
}```
--
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]