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

External Schema Imports via AVSC Schema

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.7.3
    • java
    • None
    • Reviewed
    • Schema, Import, Imports, Importing, Types, Reuse, Share

    Description

      There is no way for ".avsc" schema files to import types (i.e records, enums, etc) in external schema files. There's tremendous benefit in being able to do this as it would allow the sharing of common types between multiple schema files. Here's a use case that illustrates the typical usecase of this feature request.

      Suppose we have an enum called "Privacy" that we would like to share between multiple schemas:

      //privacy.avsc
      { 
        "type": "enum",
        "name": "Privacy",
        "symbols" : ["Public", "Private"]
      }
      

      Now, if this feature was implemented one could import the above type into other schema files by doing something like this:

      //the post.avsc 
      {
        "type": "record", 
        "name": "Post",
        "imports": ["privacy.avsc"] //you can import one or more schemas
        "fields": [{
                    "name": "privacy", 
                    "type": [ "null", "Privacy"], //use imported Privacy type
                    "default": "Private"
                  }
        ]
      }
      

      Here's another schema file that also has a similar privacy concern:

      //the event.avsc is another schema that also imports the privacy type
      {
        "type": "record", 
        "name": "Event",
        "imports": ["privacy.avsc"] //it also imports the privacy schemas
        "fields": [{
                    "name": "privacy", 
                    "type": [ "null", "Privacy"], //use imported Privacy type
                    "default": "Public"
                  }
        ]
      }
      

      IDL files are able to import external schemas and protocols and it would be very beneficial if schema files could import other schema files.

      Attachments

        1. vcs-diff4277815358664835838.patch
          5 kB
          Sharmarke Aden
        2. Avro-1188.tar.gz
          20 kB
          Sharmarke Aden
        3. vcs-diff2916139350460140957.patch
          5 kB
          Sharmarke Aden
        4. vcs-diff1160361655737792386.patch
          5 kB
          Sharmarke Aden
        5. vcs-diff6739872835137179667.patch
          5 kB
          Sharmarke Aden
        6. Avro-1188.tar.gz
          4 kB
          Sharmarke Aden

        Issue Links

          Activity

            People

              saden1 Sharmarke Aden
              saden1 Sharmarke Aden
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: