xarx
xarx

Reputation: 657

Aliases for primitive types in AVRO

I want to define aliases/logical names for primitive types. But if I do that directly like for PartyId in the example below, Avro-Tools do not accept this:

protocol Test {
    string PartyId;

    record Header {
        PartyId partyId;
    }
}

Is that possible in IDL or AVRO Schema language? How? As a work-around, I can define:

record PartyId {
    string _value;
}

Though binary this seems equivalent, semantically (e.g. in generated Java code) this is not the same - PartyId is a structured type, not a primitive type.

I can define custom names for enums and records, but it seems to me that AVRO doesn't offer means for aliasing primitive types.

Upvotes: 1

Views: 669

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191844

Aliases in Avro are for remapping of record namespaces

Names for records and enums are because these are actual objects, not primitives

Just like you cannot refer to a Java String by another class, Avro has no need for such a feature. You can write doc comments or name the fields appropriately to make it clear what each field is

Upvotes: 1

Related Questions