You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "marcosschroh (via GitHub)" <gi...@apache.org> on 2024/02/16 16:19:25 UTC
[PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
marcosschroh opened a new pull request, #2742:
URL: https://github.com/apache/avro/pull/2742
<!--
*Thank you very much for contributing to Apache Avro - we are happy that you want to help us improve Avro. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Avro a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/AVRO/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "AVRO-XXXX: [component] Title of the pull request", where *AVRO-XXXX* should be replaced by the actual issue number.
The *component* is optional, but can help identify the correct reviewers faster: either the language ("java", "python") or subsystem such as "build" or "doc" are good candidates.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests. You can [build the entire project](https://github.com/apache/avro/blob/main/BUILD.md) or just the [language-specific SDK](https://avro.apache.org/project/how-to-contribute/#unit-tests).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Every commit message references Jira issues in their subject lines. In addition, commits follow the guidelines from [How to write a good git commit message](https://chris.beams.io/posts/git-commit/)
1. Subject is separated from body by a blank line
1. Subject is limited to 50 characters (not including Jira issue reference)
1. Subject does not end with a period
1. Subject uses the imperative mood ("add", not "adding")
1. Body wraps at 72 characters
1. Body explains "what" and "why", not "how"
-->
## What is the purpose of the change
Code refactor for `schema_compatibility` module.
- Some unnecessary `else` clause have been removed
- Improve iterations with `find_map`
- Match case grouped for `SchemaKind::TimeMicros, SchemaKind::TimestampNanos, SchemaKind::TimestampMillis, SchemaKind::TimestampMicros, SchemaKind::LocalTimestampMillis, SchemaKind::LocalTimestampMicros, SchemaKind::LocalTimestampNanos` for `check_writer_type`
## Verifying this change
Code cleanup and refactor without any test coverage
## Documentation
- Does this pull request introduce a new feature? (no)
--
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: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
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 do 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: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
marcosschroh commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1494958638
##########
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:
Ah, you meant each type of the match. I get it now. It can be grouped because we can pass r_type: `vec![r_type, SchemaKind::Long]`, right ?
--
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
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
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 grouped 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: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1494882424
##########
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:
> Similar for all above
That is, the match could not be grouped.
--
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
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
marcosschroh commented on PR #2742:
URL: https://github.com/apache/avro/pull/2742#issuecomment-1948946144
@martin-g Please review when you have time
--
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
Re: [PR] AVRO-3904: [Rust] schema_compatibility module refactor [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on PR #2742:
URL: https://github.com/apache/avro/pull/2742#issuecomment-1953894137
Thank you, @marcosschroh !
--
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
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
marcosschroh commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1495559601
##########
lang/rust/avro/src/schema_compatibility.rs:
##########
@@ -430,97 +429,54 @@ 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],
Review Comment:
Good point. Let's make all the cases with `r_type` for consistency.
--
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
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
marcosschroh commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1494958638
##########
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:
Ah, you meant each type of the match. I get it now. It can be grouped because we can pass r_type: `vec![r_type, SchemaKind::Long], right ?
--
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
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1495490719
##########
lang/rust/avro/src/schema_compatibility.rs:
##########
@@ -430,97 +429,54 @@ 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],
Review Comment:
Here we have the same problem as below.
The first item in the vec must be `r_type`
--
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
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "marcosschroh (via GitHub)" <gi...@apache.org>.
marcosschroh commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1494958638
##########
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:
Ah, you meant each type of the match. I get it now. It can be grouped because we can pass r_type: `vec![r_type, SchemaKind::Long]
--
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
Re: [PR] AVRO-3904: [Rust] schema_compatibility module refactor [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g merged PR #2742:
URL: https://github.com/apache/avro/pull/2742
--
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: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NO-JIRA: [Rust] schema_compatibility module refactor [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2742:
URL: https://github.com/apache/avro/pull/2742#discussion_r1493741074
##########
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:
This is a bug introduced by me few days ago!
It must have been:
`vec![SchemaKind::LocalTimestampMicros, SchemaKind::Long],`
Similar for all above.
--
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