[
https://issues.apache.org/jira/browse/AVRO-530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17563799#comment-17563799
]
Kalle Niemitalo commented on AVRO-530:
--------------------------------------
I wonder if it would be sufficient to relax the rule like so:
bq. A schema or protocol may not contain multiple definitions of a fullname.
Further, a name must be defined before it is used ("before" in the depth-first,
left-to-right traversal of the JSON parse tree), except names of schemas
defined directly in the {{types}} attribute of a protocol (but not schemas
defined within those schemas) can be used everywhere.
That would only help with protocols though, not with standalone schemas. And I
suppose it would not be much easier to implement than full support for forward
references.
> allow for mutual recursion in type definitions
> ----------------------------------------------
>
> Key: AVRO-530
> URL: https://issues.apache.org/jira/browse/AVRO-530
> Project: Apache Avro
> Issue Type: Improvement
> Components: spec
> Affects Versions: 1.3.2
> Reporter: Jeff Hodges
> Priority: Major
>
> Suppose you have these two types in your protocol:
> {code}
> {"name": "User", "type": "record", "fields": [{"name": "current_status",
> "type": "Status"}]}
> {"name": "Status", "type": "record", "fields": [{"name": "author", "type":
> "User"}]}
> {code}
> This will raise an error! The current workaround is to define one of them at
> their first usage. Like:
> {code}
> {"name": "User", "type": "record", "fields": [{"name": "current_status",
> "type": {"name": "Status", "type": "record", "fields": [.. lots of fields
> ...]}]}
> {code}
> But this is incredibly unwieldy. It would be really nice for the spec to
> require all the parsers to allow for mutual recursion, instead. It could be
> done by implementing a two-pass parser. One pass to acquire names referenced,
> and a second to fill in those names with their appropriate references.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)