Comments (7)
Would this be possible wrt Avro schema limitations? Would new type be defined as Union, allowing both String and Enum? And which direction is the change? (older schema exception String, new Enum? Or vice versa)
At JsonGenerator
(and so AvroGenerator
subtype) level Enums are typically written using writeString()
anyway (since JSON has no "Enum" type; conversion handled at databind level).
Same for JsonParser
/AvroParser
.
So I am not 100% sure I yet understand the ask here.
from jackson-dataformats-binary.
I am suggesting an option where the generated avro schema for an enum field would simply be String.
This would enable extending the enum in the future, with no change in schema.
from jackson-dataformats-binary.
@jlous Ah ok. Depending on how implemented it might even be a general MapperFeature
; I forget what the division is between model traversal (callbacks generated on serialization settings) and construction of Avro schema.
At this point I probably won't have time to work on this in near term but would be happy to help if anyone else wants to tackle it.
from jackson-dataformats-binary.
@jlous BTW: If you change in Avro schema enum to string type, serialization and deserialization should work already.
from jackson-dataformats-binary.
I try to avoid enum in Avro schema. Serializing enum into string is a good idea.
@cowtowncoder
How do you want to control this feature?
I think creating a new AvroGenerator.Feature
would be best from API standpoint, but I do not know how to access AvroGenerator.Feature
from VisitorFormatWrapperImpl.expectStringFormat(JavaType).
BTW: Here is a draft PR, #496, where this feature is controlled by enableWriteEnumAsString()
method:
AvroSchemaGenerator gen = new AvroSchemaGenerator()
.enableWriteEnumAsString();
from jackson-dataformats-binary.
Ah. Sorry, saw this comment before adding a note on PR.
Yes, AvroGenerator.Feature
would be better but I'd need to think of plumbing.
I think AvroGenerator
might be available from SerializerProvider
but not sure if that is properly initialized.
from jackson-dataformats-binary.
Let's continue discussion in PR #496.
from jackson-dataformats-binary.
Related Issues (20)
- `IndexOutOfBoundsException` in `JacksonAvroParserImpl` for invalid input
- `IndexOutOfBoundsException` in `CBORParser` for invalid input
- Unexpected NullPointerException in `CBORParser`
- Unexpected `NullPointerException` in `ProtobufParser.currentName()`
- `ProtobufParser.currentName()` returns wrong value at root level
- Unexpected `ArrayIndexOutOfBoundsException` in `CBORParser` for corrupt String value
- IonReader.newBytes() throwing `NegativeArraySizeException` HOT 1
- `IonReader` throws `AssertionError` for Timestamp value HOT 1
- `IonReader.next()` throws `ArrayIndexOutOfBoundsException` for some corrupt content HOT 4
- Support for `StreamReadConstraints.maxNameLength` validation for CBOR, Smile backends
- protobuf LocalDateTime UnsupportedOperationException HOT 1
- Upgrade `ion-java` to latest (1.11.4)
- Upgrade `ion-java` to latest (1.11.7)
- ION deserialization type change from Double to Float in 2.17.0 HOT 7
- ION - MappingIterator skip the first line
- Issue in Smile shared string values due to avoiding 0xFE and 0xFF HOT 6
- Failed copy(): `IonValueMapper` does not override copy() HOT 1
- [AVRO] 2 fields in schema for single property when getter and setter contain property name in capitals. HOT 3
- Upgrade `ion-java` dependency to 1.11.8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jackson-dataformats-binary.