You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Santiago Fraire Willemoes (Jira)" <ji...@apache.org> on 2023/01/29 08:03:00 UTC

[jira] [Created] (AVRO-3709) [Rust] Add aliases to RecordField

Santiago Fraire Willemoes created AVRO-3709:
-----------------------------------------------

             Summary: [Rust] Add aliases to RecordField
                 Key: AVRO-3709
                 URL: https://issues.apache.org/jira/browse/AVRO-3709
             Project: Apache Avro
          Issue Type: Improvement
          Components: rust
    Affects Versions: 1.11.1
            Reporter: Santiago Fraire Willemoes


Hello everyone, I'm working on an [avdl parser for rust|https://github.com/woile/avdl-rs] and I'm having an issue with the lack of aliases on the `RecordField`.

For an Avdl like this:
{code:java}
protocol MyProtocol {
    record Hello {
        string @aliases(["nickname"]) name;
    }
}
{code}
The schema is rendered as:
{code:java}
{
  "type" : "record",
  "name" : "Hello",
  "fields" : [ {
    "name" : "name",
    "type" : "string",
    "aliases" : [ "nickname" ]
  } ]
}
{code}
But when I generate the schema on rust using the `RecordField`, it doesn't have aliases. 
See [https://github.com/apache/avro/blob/master/lang/rust/avro/src/schema.rs#L559-L580]

And even if I use `custom_attributes` with aliases, when generating the schema using `schema.canonical_form()`, they don't appear.

The `RecordField` has `custom_attributes` for unknown fields but aliases are known. See documentation here:
[https://avro.apache.org/docs/1.11.1/idl-language/#other-language-features]

The interesting thing is that the Specification doesn't mention aliases in a RecordField, but they are used widely everywhere.

I would be willing to submit a PR, not sure if there's another reason for the lack of aliases that I'm missing.

I would also like to ask for advice, is the Schema supposed to be used to generate a json schema? or is it solely for deserializing a json schema? Should I create a fork of it? I find it strange that it implements serde's serialize but it doesn't fully serialize all the attributes.

Thanks a lot.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)