[proposal] Introduce custom logicalType #173
ievgenii-shepeliuk
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Based on your examples, it seems that you’re primarily interested in cases where Chr.Avro prefers to use strings (as for ISO 8601 datetimes/durations). Is that accurate? An alternative could be to use a custom property like the Java implementation: {
"type": "string",
"avro.dotnet.type": "System.DateTime"
} I think there are some advantages to that approach, one being that it’s unlikely to conflict with the spec later. For example, if the spec ever introduced a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello
Since Avro doesn't cover all the cases of type mapping -
Chr.Avro
already uses some conventions to map from Avro schema to C# classes, like for dates, durations etc.This works fine in case when C# classes either manually created or schema is generated from C#.
But for other cases, e.g. when schema is provided by external entities (when working in polyglot ecosystem with C# / Java / Python) or in case when schema-first approach is chosen, i.e. when C# class is generated from schema during build - existing mapping approach can not be used.
So my proposal is to introduce some custom logical types - eg
chr.avro.datetime
,chr.avro.duration
,chr.avro.ipaddress
etc.Those custom types then can be used to extend
Chr.Avro
code generator to create a proper corresponding C# type when generating C# code from Avro schema. Also, such logical types can be used by other languages as a organization-wide type hints for code generation.As far as I understand, custom logical type are not contradicting Avro specification or ideology.
WDYT ?
Beta Was this translation helpful? Give feedback.
All reactions