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

Initialise all fields in a nested schema

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • java
    • None

    Description

      For testing purposes it would be nice to have a way to initialise all fields to some value even if there is no default value specified in the schema (the value is required). I noticed that for schemas that are large and have a few levels of nesting it can get quite ugly (creating all the required sub classes) when you want to instantiate a random message to do some tests.

      The possible data types in an avro schema are initialisable to some default/random value and if this is not the value desired, it can be changed at any time.

      I did a short implementation using reflection that recursively goes through the entire fields of a message  but maybe an annotation included in the avro schema (using javaAnnotation) would make more sense so that it is available only if needed. The annotation could also include some options like default or random value, overwrite existing non null members or not, ignore specific members or types.

      Attachments

        Activity

          People

            Unassigned Unassigned
            biliuta Biliuta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: