apache kafka - Issue while including enum type in unions within avro schema -


i working apache kafka send messages kafka topics. trying use unions in avro schemas including enum types message validation. facing issue usage of enum types within union. using kafka rest api through postman tool post record/message topic schema validation. below request payload including schema , records inline -

{     "key_schema": "{\"type\": \"record\", \"name\": \"key\", \"fields\": [{\"name\": \"keyinput\", \"type\": \"string\"}]}",     "value_schema": "{\"type\": \"record\", \"name\": \"value\", \"fields\": [{\"name\": \"valueinput1\", \"type\": \"string\"},{\"name\": \"valueinput2\",\"type\":[{\"type\":\"enum\",\"name\":\"actorobjtype\",\"symbols\":[\"agent\",\"group\"]},\"null\"],\"default\":null}]}",     "records": [         {             "key": {                 "keyinput": "testuser-key"             },             "value": {                 "valueinput1": "testuser-value",                 "valueinput2": "agent"             }         }     ] } 

i getting following error when trying insert record using above request payload -

{   "error_code": 42203,   "message": "conversion of json avro failed: failed convert json avro: expected start-union. got value_string" } 

after searching in different sites including stackoverflow, came through suggestion

asking explicitly specify type while passing record below -

{     "key_schema": "{\"type\": \"record\", \"name\": \"key\", \"fields\": [{\"name\": \"keyinput\", \"type\": \"string\"}]}",     "value_schema": "{\"type\": \"record\", \"name\": \"value\", \"fields\": [{\"name\": \"valueinput1\", \"type\": \"string\"},{\"name\": \"valueinput2\",\"type\":[{\"type\":\"enum\",\"name\":\"actorobjtype\",\"symbols\":[\"agent\",\"group\"]},\"null\"],\"default\":null}]}",     "records": [         {             "key": {                 "keyinput": "testuser-key"             },             "value": {                 "valueinput1": "testuser-value",                 "valueinput2": {                     "enum": "agent"                 }             }         }     ] } 

but face below error -

{   "error_code": 42203,   "message": "conversion of json avro failed: failed convert json avro: unknown union branch enum" } 

the same suggestion worked fine unions other types string , map, unions including enum, not seem work.

i thought there may other type needs used enum specification, hence tried other words below -

"valueinput2": {                     "string": "agent"                 } 

and

"valueinput2": {                     "enumeration": "agent"                 } 

but none of them seem work. please me resolve this.


Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Displaying JSON data posts for blog using just the post id -