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

Catch mismatched default values

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.3
    • 1.4.0
    • java
    • None

    Description

      Please signal an error when a field's default value isn't permitted; that is when it doesn't match the field type. In particular, when the type is a union, please signal an error if the default isn't a permitted value of the first schema in the union.

      For example, these field declarations are erroneous:

      {"name":"f1", "type":["null", "int"], "default": 3} {"name":"f2", "type":["int", "null"], "default": null}

      In the current Java implementation, schema resolution using these schemata will result in f1=null (not 3) and f2=0 (not null). This quiet choice of an unintended value is apt to cause trouble that's difficult to diagnose.

      I propose that schema parsing signal an error when attempting to parse such an erroneous schema. Another option is for schema resolution to signal an error when the reader's schema is erroneous. Schema parsing is better, I think, since it will help catch mistakes earlier, when they're cheaper to correct. It wouldn't hurt for both schema parsing and resolution to check.

      Attachments

        1. AVRO-617.patch
          3 kB
          Doug Cutting

        Activity

          People

            cutting Doug Cutting
            jkristian John Kristian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: