Anthony Miyaguchi created AVRO-2367:
---------------------------------------

             Summary: FieldActionAdjust should include default value
                 Key: AVRO-2367
                 URL: https://issues.apache.org/jira/browse/AVRO-2367
             Project: Apache Avro
          Issue Type: Improvement
          Components: java
    Affects Versions: 1.8.2
            Reporter: Anthony Miyaguchi


The FieldAdjustAction is an implicit action symbol used within the 
JsonGrammarGenerator. It provides the production rules for reading and writing 
object fields.

 

I am currently writing a custom Json decoder that can handle 
missing/non-required fields based on the reader's schema. With a [small 
workaround|https://github.com/acmiyaguchi/gcp-ingestion/commit/fc6c676dc0784ca3470c3ef19b4896663052ee45],
 I can handle fields where the intended default is null. However, I would like 
to insert the non-null default values. This is not possible because the default 
value in the schemas are missing from the symbol set.

 
{code:java}
{"type": ["null", "boolean"], "default": null} // can be emulated
{"type": ["boolean", "null"], "default": true} // not enough information
{code}
The solution would be to include the default value (JsonNode) as a member of 
the FieldAdjustAction. This would be backwards compatible with the current 
code, while allowing custom decoders to insert default values for union values.

 

[https://github.com/apache/avro/blob/3a7786ed1a3bedf05e6bce7924aea2f75b576912/lang/java/avro/src/main/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java#L85]

[https://github.com/apache/avro/blob/3a7786ed1a3bedf05e6bce7924aea2f75b576912/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java#L582-L597]

 

 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to