You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Slava D (Jira)" <ji...@apache.org> on 2020/12/03 13:02:00 UTC

[jira] [Created] (AVRO-2996) GenericDatumWriter does not support writing UUID in Java

Slava D created AVRO-2996:
-----------------------------

             Summary: GenericDatumWriter does not support writing UUID in Java
                 Key: AVRO-2996
                 URL: https://issues.apache.org/jira/browse/AVRO-2996
             Project: Apache Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.10.0
         Environment: Kotlin language

using 
{code:java}
org.apache.avro:avro:1.10.0
{code}
            Reporter: Slava D


GenericDatumWriter writer fails to serialize UUID fields from DTOs generated from AVRO schemas.

Serialization code (in Kotlin):

 
{code:java}
val writer = GenericDatumWriter<SpecificRecord>(payload.schema)
val baos = ByteArrayOutputStream()
val jsonEncoder = EncoderFactory.get().jsonEncoder(payload.schema, baos)
writer.write(payload, jsonEncoder)
{code}
 

Example of Schema:

 
{code:java}
{
 "name": "AvroWithUUID", 
 "namespace": "com.example.avro",
 "type": "record",
 "fields": [
    { "name": "id", "type": { "type": "string", "logicalType": "uuid" } },
    { "name": "external_id", "type": "string" }
 ]
}
{code}
A SpecificRecord class was generated from this code, using conversion to create UUID fields where logicalType is: "uuid"

The specific failure occurs at

GenericDatumWriter.java#writeWithoutConversion at "case STRING:"

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)