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

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -