confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
57 stars 860 forks source link

Logical type 'UUID' is not supported #2039

Open fuckyougivemeausername opened 1 year ago

fuckyougivemeausername commented 1 year ago

Description

I'm trying to consume a complex type which features, in the schema, several fields which are listed as "logicalType": "UUID". For example:

{ "name": "id", "type": { "avro.java.string": "String", "logicalType": "UUID", "type": "string" } }

I tried to create a .net object to match this using Avrogen but I got an error on these fields, stating that UUID was not supported. However, all the fields in question were string fields so I just removed the logicalType from the schema and got a code object generated.

However, when I try to consume messages using the confluent kafka package, I get what's essentially the same error:

Confluent.Kafka.ConsumeException: Local: Value deserialization error ---> Avro.AvroTypeException: Logical type 'UUID' is not supported.

I can't find any references to this when searching on Google or in this repo.

How to reproduce

KalleOlaviNiemitalo commented 1 year ago

According to the Avro spec, "uuid" must be lower case, so the bug is in the schema.

If you have already registered a schema with upper-case "logicalType": "UUID" and need to consume messages using that, then you may be able to work around the problem by calling Avro.Util.LogicalTypeFactory.Instance.Register(LogicalType) with an instance of a custom class whose constructor calls base("UUID").

KalleOlaviNiemitalo commented 1 year ago

Also, [AVRO-3012] Unknown logical types are not ignored during deserialization but lead to an exception. If that were fixed, then the Avro C# library would ignore "logicalType": "UUID". Not throw an exception like now, and not attempt to convert the string to System.Guid like it does with "logicalType": "uuid".