Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-530

allow for mutual recursion in type definitions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.2
    • 1.12.0
    • spec

    Description

      Suppose you have these two types in your protocol:

      {"name": "User", "type": "record", "fields": [{"name": "current_status", "type": "Status"}]}
      
      {"name": "Status", "type": "record", "fields": [{"name": "author", "type": "User"}]}
      

      This will raise an error! The current workaround is to define one of them at their first usage. Like:

      {"name": "User", "type": "record", "fields": [{"name": "current_status", "type": {"name": "Status", "type": "record", "fields": [.. lots of fields ...]}]}
      

      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.

      Attachments

        Issue Links

          Activity

            People

              clesaec Christophe Le Saec
              jmhodges Jeff Hodges
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m