avsc icon indicating copy to clipboard operation
avsc copied to clipboard

Support for circular references in AVDL (Avro IDL)

Open MichaelHirn opened this issue 5 years ago • 2 comments

I understand that circular schema references (see example below) are supported for avsc schemas, however I was not able to get them working in avdl schemas; they will error when compiled to avsc schemas with the usual 'undefined type name' error, as the declaration order of records in avdl matters.

// this will not compile with avsc
record SampleNode {
  int count = 0;
  array<SamplePair> samples = [];
}
record SamplePair {
 string name;
 SampleNode node;
}

Judging from avro's issue tracker, support for circular references landed in v1.9 (source) - is there any way in avsc lib that supports circular references in avdl today or would avsc need to upgrade to avro v1.9 specification?

ref: #238

MichaelHirn avatar Jun 14 '20 20:06 MichaelHirn

Hi @MichaelHirn. Thanks for bringing this up, I wasn't aware of this v1.9 change. avsc does not currently support this type of IDL but probably should. How urgent is this feature from your side?

In case it's useful: avsc already supports IDL files with circular references using the following (non-standard now, since it predates the v1.9 change and was modeled on .avsc declarations) syntax:

record SampleNode {
  int count = 0;
  array < record SamplePair { // "Inline declaration".
    string name;
    SampleNode node;
  } > samples = [];
}

(You can even omit the < and > delimiters, as they tend to clutter definitions.)

mtth avatar Jun 16 '20 14:06 mtth

Hi @mtth, thanks for your response. The inline declaration is very helpful - I think that would probably be sufficient for us for now. I will be able to use inline declaration (and circular dependencies) more in the next days and weeks and would circle back with any updates.

Thanks for you help on this one :)

MichaelHirn avatar Jun 18 '20 10:06 MichaelHirn