|
Hi zhoujiazhiwork@163.com,
Thank you for reaching out. The Avro schema parser doesn't accept the avro schema definition. The cause is because the fullDocument type cannot defined as a record inline using that syntax, it has to be nested. Its a pain because its shorter than the official way, which is to nest the record definition in its own object:
String jsonSchema = ""
|
+ "{\"name\":\"keySchema\", \"type\":\"record\", \"fields\": ["
|
+ " {\"name\": \"fullDocument\", \"type\": {"
|
+ " \"type\": \"record\", \"name\": \"fullDocumentRecord\","
|
+ " \"fields\": ["
|
+ " {\"name\": \"a\", \"type\": \"string\"},"
|
+ " {\"name\": \"b\", \"type\": \"string\"},"
|
+ " {\"name\": \"c\", \"type\": \"string\"}]"
|
+ " }"
|
+ " }"
|
+ "]}";
|
Personally, I'd prefer a shorter method but the official org.apache.avro.Schema.Parser won't accept it.
For future reference I wanted to give you some resources to get this question answered more quickly in the future.
- Our MongoDB support portal, located at support.mongodb.com
- Our MongoDB community portal, located here
- If you are an Atlas customer, there is free support offered 24/7 in the lower right hand corner of the UI
All the best,
Ross Lawley
|