auraseb opened a new issue, #11729:
URL: https://github.com/apache/arrow-rs/issues/11729

   **Describe the bug**
   
   The Avro spec says a name that contains a dot is a full name: its namespace 
attribute is ignored, and types nested inside it inherit the namespace taken 
from that name. `arrow-avro` does not apply this rule when it registers named 
types for later references, so valid schemas fail with `Failed to resolve ...`.
   
   Two cases fail today:
   
   1. A type declared as `"name": "ns.Status"` and then referenced as 
`"ns.Status"`.
   2. A type nested in a record named `"com.example.Event"` (no `namespace` 
attribute) and referenced by its full name, for example `"com.example.Kind"`.
   
   **To Reproduce**
   
   ```rust
   use arrow_avro::reader::ReaderBuilder;
   use arrow_avro::schema::{AvroSchema, SchemaStore};
   
   let schema = AvroSchema::new(
       r#"{
         "type": "record",
         "name": "com.example.Event",
         "fields": [
           {"name": "kind", "type": {"type": "enum", "name": "Kind", "symbols": 
["A", "B"]}},
           {"name": "previous_kind", "type": "com.example.Kind"}
         ]
       }"#
       .to_string(),
   );
   let mut store = SchemaStore::new();
   store.register(schema).unwrap();
   let decoder = ReaderBuilder::new()
       .with_writer_schema_store(store)
       .build_decoder();
   // Err(ParseError("Failed to resolve com.example.Kind"))
   println!("{:?}", decoder.err());
   ```
   
   The same error is returned when reading an Object Container File whose 
embedded schema uses dotted names this way.
   
   **Expected behavior**
   
   Both schemas are valid Avro and should parse. `com.example.Kind` should 
resolve to the enum declared in the first field.
   
   **Additional context**
   
   In `arrow-avro/src/codec.rs`, `Resolver::resolve` splits a dotted reference 
into `(namespace, name)`, but `Resolver::register` stores the declared name as 
is under the namespace attribute (or the enclosing namespace). A type declared 
as `ns.Status` is therefore stored under `("", "ns.Status")` and looked up 
under `("ns", "Status")`. In addition, `Maker` computes the namespace passed to 
nested types as `r.namespace.or(namespace)`, which ignores the namespace 
carried by a dotted record name.
   
   `make_full_name` in `schema.rs` already implements the rule correctly for 
fingerprints and union branch names.


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

Reply via email to