Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.10.1
-
None
-
None
Description
Current Java generator modifies the source schema to add a property to describe the way a reader decodes a string. (see AVRO-2918)
I think this is a design problem. The way a reader deserializes a string shouldn't modify the schema (the schema describes the structure of avro message, not the way a reader converts to a usable form).
On the other hand, a reader might require the strings as a CharSequence because it knows how to handle them and other as a String.
The only way to do this now is modifying the schema itself in each reader. If you use Avro with other technologies like Kafka (or confluent) It migth be non-viable.
I think that the way a reader decodes messages should be specified by the reader and It'll be desirable to specify this using a configuration.
Maybe if a System property (like useCustomCoders feature) or something similar could be added to modify the default value for String decoding.
Form GenericDatumReader
protected Class findStringClass(Schema schema) { String name = schema.getProp(GenericData.STRING_PROP); if (name == null) return CharSequence.class; switch (GenericData.StringType.valueOf(name)) { case String: return String.class; default: return CharSequence.class; } }
Maybe adding a "forced" configuration may help: if reader configures string representation, use it, if not do it the current way.
And do something similar in SpecificDatumReader
Attachments
Issue Links
- is related to
-
AVRO-2838 Schema in generated Java class is different than the original one
- Open