[ 
https://issues.apache.org/jira/browse/AVRO-3466?focusedWorklogId=745512&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-745512
 ]

ASF GitHub Bot logged work on AVRO-3466:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Mar/22 23:11
            Start Date: 21/Mar/22 23:11
    Worklog Time Spent: 10m 
      Work Description: jklamer opened a new pull request #1617:
URL: https://github.com/apache/avro/pull/1617


   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [ ] My PR addresses the following [Avro 
Jira](https://issues.apache.org/jira/browse/AVRO-3466) 
   
   ### Tests
   
   - [ ] Two tests that fail without the change
   
   ### Commits
   
   ### Documentation
   No new functionality. 


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


Issue Time Tracking
-------------------

            Worklog Id:     (was: 745512)
    Remaining Estimate: 0h
            Time Spent: 10m

> Rust: serialize Schema to JSON loses inner namespace names
> ----------------------------------------------------------
>
>                 Key: AVRO-3466
>                 URL: https://issues.apache.org/jira/browse/AVRO-3466
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: rust
>    Affects Versions: 1.11.1
>         Environment: stable-x86_64-apple-darwin (default)
> rustc 1.56.1 (59eed8a2a 2021-11-01)
> apache-avro git commit a4e42112cea95 (master at the time)
>  
>            Reporter: Kevin
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Inner namespace for {{enum}} type in a Record field is lost when Schema 
> serialized to JSON.
> An example failing Unit test for {{schema.rs}} demonstrates the problem:
> {code:java}
> #[test]
> fn kvc_test_to_json_inner_enum_inner_namespace() {
>     let schema = r#"
>     {
>       "name": "record_name",
>       "namespace": "space",
>       "type": "record",
>       "fields": [
>         {
>           "name": "outer_field_1",
>           "type": [
>                     "null",
>                     {
>                         "type":"enum",
>                         "name":"inner_enum_name",
>                         "namespace": "inner_space",
>                         "symbols":["Extensive","Testing"]
>                     }
>                 ]
>         },
>         {
>             "name": "outer_field_2",
>             "type" : "inner_space.inner_enum_name"
>         }
>       ]
>     }
>     "#;
>     let schema = Schema::parse_str(schema).unwrap();
>     let rs = ResolvedSchema::try_from(&schema).expect("Schema didn't 
> successfully parse");
>     // confirm we have expected 2 full-names
>     assert!(rs.get_names().len() == 2);
>     for s in &["space.record_name", "inner_space.inner_enum_name"] {
>         assert!(rs.get_names().contains_key(&Name::new(s).unwrap()));
>     }
>     // convert Schema back to JSON string
>     // BUG: this operation loses the inner enum namespace "inner_space"
>     let schema = serde_json::to_string(&schema).expect("test failed");
>     println!("{}", schema);
>     // confirm we can parse it again, this fails because JSON string lost 
> inner enum namespace
>     let _schema = Schema::parse_str(&schema).expect("test failed");
> } {code}
> above run against recent {{master}} (commit ) fails with:
> {code:java}
> {"type":"record","namespace":"space","name":"record_name","fields":[{"name":"outer_field_1","type":["null",{"type":"enum","name":"inner_enum_name","symbols":["Extensive","Testing"]}]},{"name":"outer_field_2","type":"inner_space.inner_enum_name"}]}test
>  failed: ParsePrimitive("inner_space.inner_enum_name")
> thread 'schema::tests::kvc_test_to_json_inner_enum_inner_namespace' panicked 
> at 'test failed: ParsePrimitive("inner_space.inner_enum_name")', 
> avro/src/schema.rs:2862:50
>  {code}
> Notice in the above that {{inner_enum_name}} in the output JSON is lacking 
> the {{namespace}} attribute of the input JSON.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to