You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ZENOTME (via GitHub)" <gi...@apache.org> on 2024/01/26 03:05:46 UTC

[PR] fix array/map deserilaize with custom attribute [avro]

ZENOTME opened a new pull request, #2708:
URL: https://github.com/apache/avro/pull/2708

   <!--
   
   *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
   
   For deserializing list && map with custom attribute, it will ignore the custom attributes. And this case also miss in test. This PR fixes them:
   1. fix the deserialized behavior
   2. fix the test 
   
   ## Verifying this change
   
   *(Please pick one of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
   - *Extended interop tests to verify consistent valid schema names between SDKs*
   - *Added test that validates that Java throws an AvroRuntimeException on invalid binary data*
   - *Manually verified the change by building the website and checking the new redirect*
   
   
   ## Documentation
   
   - Does this pull request introduce a new feature? (yes / no)
   - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   


-- 
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] AVRO-3927: [Rust] fix array/map deserilaize with custom attribute [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1487601998


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   Thanks! I will keep that in mind and start to work on it after the holidays!



-- 
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-3927: [Rust] fix array/map deserilaize with custom attribute [avro]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g merged PR #2708:
URL: https://github.com/apache/avro/pull/2708


-- 
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] fix array/map deserilaize with custom attribute [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1467183416


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   This may not be a good way to fix it. For PartialEq of schema, it will compare `Canonical Form`. Can we add an interface to compare the whole schema?🤔 cc @martin-g 



-- 
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-3927: [Rust] fix array/map deserilaize with custom attribute [avro]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1487414784


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   @ZENOTME  Please let me know if you need help with this!
   I will have some more free time in the coming days!



-- 
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-3927: [Rust] fix array/map deserilaize with custom attribute [avro]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1491003430


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   https://issues.apache.org/jira/browse/AVRO-3939
   https://github.com/apache/avro/pull/2739



-- 
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-3927: [Rust] fix array/map deserilaize with custom attribute [avro]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1470772936


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   Yes! Sorry if I was not clear!
   I think this is what you meant with `Can we add an interface`



-- 
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] fix array/map deserilaize with custom attribute [avro]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1467261036


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   This is something that I wanted to address since a while but I have forgotten about it.
   Currently to compare two `Schema`s the code will convert them to their `canonical form` (JSON String) and then compare them.
   This is what the Avro specification says!
   
   But CPU profiling shows that this implementation is slow! 
   IMO it would be better to traverse the schemas and compare their fields. This way if their names are different the comparison will return early.
   
   By using an interface (trait) we can have: 
   - a default impl that follows the Avro specification and ignores the non-essential fields
   - custom impls which define their own rules
   
   See the new validators for inspiration.



-- 
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-3927: [Rust] fix array/map deserilaize with custom attribute [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1470786448


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   Thanks! I'm glad to help with this.



-- 
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-3927: [Rust] fix array/map deserilaize with custom attribute [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #2708:
URL: https://github.com/apache/avro/pull/2708#discussion_r1470760959


##########
lang/rust/avro/src/schema.rs:
##########
@@ -6551,7 +6568,12 @@ mod tests {
             r#"{"field-id":"1","type":"map","values":"long"}"#,
             &serialized
         );
-        assert_eq!(expected, Schema::parse_str(&serialized)?);
+        let actual_schema = Schema::parse_str(&serialized)?;
+        assert_eq!(expected, actual_schema);
+        assert_eq!(

Review Comment:
   Sorry for replying late. Validator solution is a nice way. But I find that seems it only used in validation of parse schema now, Do you mean that we can use the similar solution for the compare way? 🤔



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