Open majisourav99 opened 2 years ago
Are you asking for an exception to be thrown, instead of silently dropping the default?
Using the avro-util AvroCompatibilityHelper default getter method, we should set the correct default value.
I think it's more correct to throw an exception. Silently turning invalid default values into valid ones seems like it would just mask issues that originate/happen elsewhere.
there is a bug in avro 1.9 if int default values are provided for float fields. we should be able to work around it in helper code. also worth having a spotbugs rule for use of the defaultVal() method perhaps as it is vulnerable to this bug in 1.9?
The helper builder drops the default value if the default value type does not match, eg if 0 is a default value of field type float then the following code will silently drop the default
public FieldBuilder19(Schema.Field other) { if (other != null) { _name = other.name(); _schema = other.schema(); _doc = other.doc(); _defaultVal = other.defaultVal(); // Its null for Avro 1.9+ _order = other.order(); // other.order() cannot be null under Avro 1.9.* _props = other.getObjectProps(); } }