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

Optional fields should not require a default value set to null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • None
    • None
    • java
    • None

    Description

      The Avro Schema Specification states that when a field has type Union, the type of its default value must match the first type in the Union. This quite useful when defining optional fields, we just need to define the Field type as Union and place the null type in the first index of the type array.

      When parsing an Avro Schema represented in JSON with the Schema.Parser class, one has to set the field default to null, even with the type is defined as Union and null is in the first index of the type array.

      The Schema.Parser should handle this corner case gracefully and allow omitting the default value key for fields with type Union and its first type null.

      Attachments

        1. AVRO-3913.patch
          2 kB
          Joao Antonio

        Activity

          People

            Unassigned Unassigned
            joaopedroantonio Joao Antonio
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: