Avro Schema - what is "avro.java.string": "String"
Asked Answered
P

1

13

I've got my Kafka Streams processing configuration for AUTO_REGISTER_SCHEMAS set to true.

I noticed in this auto generated schema it creates the following 2 types

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

Could someone please explain why it creates 2 types and what exactly "avro.java.string": "String" is.

Thanks

Promulgate answered 23/4, 2018 at 5:55 Comment(4)
There's only one type. It's a string, but it's clarified to a specific subclassSlapdash
Is this going to be a problem when a Python client tries to work with this schema?Dodder
The behavior of the class generator which modifies schemas by replacing AVRO strings with Java specific logical types is a bug: issues.apache.org/jira/browse/AVRO-2838 as it does indeed become a problem with interoperability with Python and other languagesDodder
Confluent has added a property that can be set on the serializer to prevent this from occurring: avro.remove.java.propertiesBrushoff
L
14

By default Avro uses CharSequence for the String representation, the following syntax allows you to overwrite the default behavior and use java.lang.String as the String type for the instances of the fields declared like this

"type": {
        "type": "string",
        "avro.java.string": "String"
      }
Levona answered 23/4, 2018 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.