- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Avro Schema field to accept string and dynamic array
- Labels:
-
Apache Kafka
-
Schema Registry
Created 08-02-2024 05:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Team,
I am trying to create an AVRO schema where a field can accept both string data(Expected Format 2) and a dynamic array (Expected Format 1).
AVRO schema has event/processFlow/characteristic []/value which is supposed to accept both dynamic array and string. For the “object_avro”, we are passing “object_json” as input. However as per "object_avro it is accepting only Expected Format 1 JSON block.
Kindly provide us a solution where an AVRO schema can accept both Expected Format 1 and Expected Format 2 JSON's.
Avro Schema:
{
"doc": "Sample schema to help you get started",
"fields": [
{
"name": "event",
"type": {
"fields": [
{
"name": "processFlow",
"type": {
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "characteristic",
"type": {
"items": {
"fields": [
{
"default": null,
"name": "id",
"type": [
"null",
"string"
]
},
{
"default": null,
"name": "name",
"type": [
"null",
"string"
]
},
{
"default": null,
"name": "valueType",
"type": [
"null",
"string"
]
},
{
"name": "value",
"type": {
"items": {
"type": "map",
"values": [
"string",
"null",
"int",
"boolean"
]
},
"type": "array"
}
},
{
"default": null,
"name": "baseType",
"type": [
"null",
"string"
]
},
{
"default": null,
"name": "schemaLocation",
"type": [
"null",
"string"
]
},
{
"default": null,
"name": "type",
"type": [
"null",
"string"
]
}
],
"name": "characteristic",
"type": "record"
},
"type": "array"
}
}
],
"name": "processFlow",
"type": "record"
}
}
],
"name": "event",
"type": "record"
}
}
],
"name": "processFlowManagement",
"namespace": "value.stc.b2b.processFlowManagement",
"type": "record"
}
Expected Format 1
"value":[
{
"name":{"string":"abcd"},
"partnerId":{"int":123},
"partnerType":{"boolean":true}
},
{
"custom":{"string":"abcd"},
"id":{"int":123},
"partnerType":{"boolean":true}
}
]
Expected Format 2
"value":{"string":"hello"}
has context menu
Created 08-05-2024 02:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@albelide, Welcome to our community! To help you get the best possible answer, I have tagged our Kafka experts @Babasaheb @Yuexin Zhang who may be able to assist you further.
Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.
Regards,
Vidya Sargur,Community Manager
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:
