You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Biliuta (Jira)" <ji...@apache.org> on 2020/09/30 15:05:00 UTC

[jira] [Created] (AVRO-2934) Initialise all fields in a nested schema

Biliuta created AVRO-2934:
-----------------------------

             Summary: Initialise all fields in a nested schema
                 Key: AVRO-2934
                 URL: https://issues.apache.org/jira/browse/AVRO-2934
             Project: Apache Avro
          Issue Type: Improvement
          Components: java
            Reporter: Biliuta


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. 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)