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 2023/12/25 03:56:00 UTC

[PR] AVRO-3920: Serialize custom attribute in RecordField [avro]

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

   <!--
   
   *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 example: This pull request improves file read performance by buffering data, fixing AVRO-XXXX.)*
   support to serialize the custom attributes in RecordField ,fixing AVRO-3920
   
   
   ## 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-3920: Serialize custom attribute in RecordField [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on PR #2650:
URL: https://github.com/apache/avro/pull/2650#issuecomment-1880353697

   > @ZENOTME I think this PR is good to go!
   Please let me know if you have any concerns!
   
   Sorry for being late. Thanks for your help! 
   
   > I have the feeling that the way I ignored logicalType to be stored in the custom attributes would break your expectations about Fixed+uuid. 
   But I wonder whether keeping the logicalType as a custom attribute is good in general.
   
   Yes, ignored logicalType here may couse unexpectation behaviour. I think keeping  keeping the logicalType as a custom attribute is reasonable behaviour because it let the user customiaze their own logical type even it's not supported by RustSDK. 
   
   I guess the behaviour we ignore `logicalType` or other field here is to avoid duplication. So should we only ignore the `logicalType` when the schema in record field used it? e.g Uuid, Date, TimeMills,...


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   But `symbols`  must be excluded according to https://github.com/apache/avro/blob/cc9d99bb94fcd8dd42416c58b7b633e4fd1bfa3b/lang/rust/avro/src/schema.rs#L1675


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   I'll be able to help more 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-3920: Serialize custom attribute in RecordField [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on PR #2650:
URL: https://github.com/apache/avro/pull/2650#issuecomment-1868751043

   Find a interesting case:
   ```
   let schema = Schema::parse_str(
               r#"
               {
                 "type" : "record",
                 "name" : "record",
                 "fields" : [
                    {
                       "type" : "enum",
                       "name" : "enum",
                       "symbols": ["one", "two", "three"]
                    },
                    { "name" : "next", "type" : "enum" }
                ]
               }
           "#,
           )?;
   // schema 
   RecordField {
                   name: "enum",
                   doc: None,
                   aliases: None,
                   default: None,
                   schema: Enum(
                       EnumSchema {
                           name: Name {
                               name: "enum",
                               namespace: None,
                           },
                           aliases: None,
                           doc: None,
                           symbols: [
                               "one",
                               "two",
                               "three",
                           ],
                           default: None,
                           attributes: {},
                       },
                   ),
                   order: Ascending,
                   position: 0,
                   custom_attributes: {
                       "symbols": Array [
                           String("one"),
                           String("two"),
                           String("three"),
                       ],
                   },
               },
   ```
   `"symbols": ["one", "two", "three"]` will be treated as custom attributes and symbols, seems there are some problem here:
   1. Is that str valid? Should it write as 
   ```
   r#"
               {
                 "type" : "record",
                 "name" : "record",
                 "fields" : [
                    {
                       "name": "enum"
                       "type" : {
                             "type": "enum",
                             "name" : "enum",
                              "symbols": ["one", "two", "three"]
                       }
                    },
                    { "name" : "next", "type" : "enum" }
                ]
               }
           "#,
   
   ```
   I tried this one and the symbols will not be treated as custom attributes.
   2. If the above 1 is right, then we should treat symbols in following case as attributes as custom attributes rather than symbols, right?🤔 
   ```
      "fields" :[{
                       "type" : "enum",
                       "name" : "enum",
                       "symbols": ["one", "two", "three"]
        }]
   ```
   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-3920: Serialize custom attribute in RecordField [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on PR #2650:
URL: https://github.com/apache/avro/pull/2650#issuecomment-1869199690

   I send a commit to fix it. But I'm not sure whether it is a good way to solve it. 
   IMO, I think the better way to fix it may be to let the `parse_complex(&mut self, complex:&mut Map<>)` remove some fields used in this function.🤔 But this would involve too many modifications and I'm not sure it's acceptable. 
   I'm glad to revert the current fix way and using a better way to fix it.


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   I am going to merge this PR.
   If there is more work we can do it in a separate PR!


-- 
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-3920: Serialize custom attribute in RecordField [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on PR #2650:
URL: https://github.com/apache/avro/pull/2650#issuecomment-1868765649

   > I'll be able to help more after the holidays! 
   
   Thanks! Enjoy your holiday!


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   @ZENOTME I think this PR is good to go!
   Please let me know if you have any concerns!


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   OK! I'll see how to improve it!


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   it seems it is parsed here - https://github.com/apache/avro/blob/cc9d99bb94fcd8dd42416c58b7b633e4fd1bfa3b/lang/rust/avro/src/schema.rs#L773


-- 
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-3920: Serialize custom attribute in RecordField [avro]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on PR #2650:
URL: https://github.com/apache/avro/pull/2650#issuecomment-1868760452

   > But `symbols` must be excluded according to
   > 
   > https://github.com/apache/avro/blob/cc9d99bb94fcd8dd42416c58b7b633e4fd1bfa3b/lang/rust/avro/src/schema.rs#L1675
   
   If we solve it like this, it means that the user should not use "symbols" as attribute names even the type is not an enum, like the following, right? 🤔
   ```
   fields: [{
     "type": "long",
     "name": "field1"
     "symbols":  [..]
   }]
   ```


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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


##########
lang/rust/avro/src/schema.rs:
##########
@@ -3305,16 +3314,16 @@ mod tests {
 
         let schema = Schema::parse_str(raw_schema)?;
         assert_eq!(
-            "abf662f831715ff78f88545a05a9262af75d6406b54e1a8a174ff1d2b75affc4",
+            "b18ddbf029afaa876b54cb4de997506ef67e202bee13d8b54cb5698288c25318",

Review Comment:
   I think this is a regression.
   According to https://avro.apache.org/docs/1.11.1/specification/#transforming-into-parsing-canonical-form we should `STRIP` everything but `type, name, fields, symbols, items, values, size`. I.e. the custom attributes should be stripped and the fingerprint should stay the same.



-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   The symbols should not be stored as attributes! It is a bug!


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   > If we solve it like this, it means that the user should not use "symbols" as attribute names even the type is not an enum, like the following, right?
   
   See the surrounding code. `symbols` is excluded here only if this is an `enum` schema


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   Thank you, @ZENOTME !


-- 
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-3920: Serialize custom attribute in RecordField [avro]

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

   I have the feeling that the way I ignored `logicalType` to be stored in the custom attributes would break your expectations about `Fixed+uuid`, https://github.com/apache/avro/blob/e5ca1517b7d80454fa7137e3ef53b4335416de09/lang/rust/avro/src/schema.rs#L6285-L6286
   
   There is a discussion about making `Fixed(size=16, logicalType=uuid)` a valid type! It should be available in the Rust SDK soon!
   But I wonder whether keeping the `logicalType` as a custom attribute is good in general.


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