[ https://issues.apache.org/jira/browse/AVRO-3466?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated AVRO-3466: --------------------------------- Labels: pull-request-available (was: ) > 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 > Labels: pull-request-available > 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)