Johnabell commented on PR #2954:
URL: https://github.com/apache/avro/pull/2954#issuecomment-2173138221

   > > since avro supports both default values on fields and enums
   > 
   > Someone else said the opposite ... I am not sure what to do here.
   
   Based on the [avro 
specification](https://avro.apache.org/docs/1.11.1/specification) it appears to 
be supported in both enums and record fields:
   
   1. [Enums](https://avro.apache.org/docs/1.11.1/specification/#enums)
   2. [Record 
fields](https://avro.apache.org/docs/1.11.1/specification/#schema-record)
   
   My understanding it that they have slightly different use cases:
   
   A field default mean the value of a field need not be provided. In this way 
consumers can continue to consume records based on schemas where the field is 
missing.
   
   The default value on a enum is to prevent the addition of a new variant as 
being a breaking change. In such case a client is able to use the default value 
when it encounters a variant it does not recognise. This would not be solved by 
a default on the field since the value is being provided, but is not one that 
the consumer knows about in its schema. So it would reject the message as being 
inconsistent with the schema it is using. However, when the default value is 
set on the enum it is able to use this value instead and therefore ensure 
compatibility when new variants are added.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to