marcosschroh commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1495027006


##########
lang/rust/avro/src/schema_compatibility.rs:
##########
@@ -430,96 +429,53 @@ impl SchemaCompatibility {
                     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);
-                        } else {
-                            return Err(CompatibilityError::TypeExpected {
-                                schema_type: String::from("readers_schema"),
-                                expected_type: vec![SchemaKind::Map],
-                            });
                         }
-                    } else {
+
                         return Err(CompatibilityError::TypeExpected {
-                            schema_type: String::from("writers_schema"),
+                            schema_type: String::from("readers_schema"),
                             expected_type: vec![SchemaKind::Map],
                         });
                     }
+
+                    return Err(CompatibilityError::TypeExpected {
+                        schema_type: String::from("writers_schema"),
+                        expected_type: vec![SchemaKind::Map],
+                    });
                 }
                 SchemaKind::Array => {
                     if let Schema::Array(w_a) = writers_schema {
                         if let Schema::Array(r_a) = readers_schema {
                             return 
SchemaCompatibility::match_schemas(&w_a.items, &r_a.items);
-                        } else {
-                            return Err(CompatibilityError::TypeExpected {
-                                schema_type: String::from("readers_schema"),
-                                expected_type: vec![SchemaKind::Array],
-                            });
                         }
-                    } else {
+
                         return Err(CompatibilityError::TypeExpected {
-                            schema_type: String::from("writers_schema"),
+                            schema_type: String::from("readers_schema"),
                             expected_type: vec![SchemaKind::Array],
                         });
                     }
+
+                    return Err(CompatibilityError::TypeExpected {
+                        schema_type: String::from("writers_schema"),
+                        expected_type: vec![SchemaKind::Array],
+                    });
                 }
-                SchemaKind::Date => {
-                    return check_writer_type(
-                        writers_schema,
-                        Schema::Date,
-                        vec![SchemaKind::Date, SchemaKind::Int],
-                    );
-                }
-                SchemaKind::TimeMillis => {
+                SchemaKind::Date | SchemaKind::TimeMillis => {
                     return check_writer_type(
                         writers_schema,
-                        Schema::TimeMillis,
+                        readers_schema,
                         vec![SchemaKind::Date, SchemaKind::Int],
                     );
                 }
-                SchemaKind::TimeMicros => {
-                    return check_writer_type(
-                        writers_schema,
-                        Schema::TimeMicros,
-                        vec![SchemaKind::TimeMicros, SchemaKind::Long],
-                    );
-                }
-                SchemaKind::TimestampNanos => {
-                    return check_writer_type(
-                        writers_schema,
-                        Schema::TimestampNanos,
-                        vec![SchemaKind::TimeMicros, SchemaKind::Long],
-                    );
-                }
-                SchemaKind::TimestampMillis => {
-                    return check_writer_type(
-                        writers_schema,
-                        Schema::TimestampMillis,
-                        vec![SchemaKind::TimeMicros, SchemaKind::Long],
-                    );
-                }
-                SchemaKind::TimestampMicros => {
-                    return check_writer_type(
-                        writers_schema,
-                        Schema::TimestampMicros,
-                        vec![SchemaKind::TimeMicros, SchemaKind::Long],
-                    );
-                }
-                SchemaKind::LocalTimestampMillis => {
-                    return check_writer_type(
-                        writers_schema,
-                        Schema::LocalTimestampMillis,
-                        vec![SchemaKind::TimeMicros, SchemaKind::Long],
-                    );
-                }
-                SchemaKind::LocalTimestampMicros => {
-                    return check_writer_type(
-                        writers_schema,
-                        Schema::LocalTimestampMicros,
-                        vec![SchemaKind::TimeMicros, SchemaKind::Long],

Review Comment:
   All of them have a `type: long`, so using `r_type` will make the trick and 
we can group all of them :-) 



-- 
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]

Reply via email to