Importing Confluent Schema Registry schemas into Schema Registry
If you are migrating away from Confluent's Schema Registry, you can use the schema-import tool to import your schemas to the Schema Registry service.
Confluent Schema Registry stores all schemas in a Kafka topic usually named _schemas. To import these schemas, copy the content to a text file and upload to Schema Registry service.
You must have the export-import access policy with the Create permission assigned to your user account.
For more information on Schema Registry access policies, see Schema Registry Authorization through Ranger Access Policies.
-
JSON Parsing Failure due to Comments
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)The Avro schema definition contains comments. The JSON parser that Schema Registry uses does not permit comments because it follows the JSON specification. Schemas exported from Confluent Schema Registry might include these non-standard comments.
To resolve this error:
- Remove all comments from the schema definition before you import it.
- To find comments, run the following command:
grep -nE '^\s*//|/\*|\*/' - Delete the comments.
- Retry the import with the cleaned schema file.
-
Invalid Default Value in Union Field
org.apache.avro.AvroTypeException: Invalid default for field VERSION: "0" not a ["null","string"]The default value for a field does not match the first type in the union. For example, the following field is invalid because the default is a string but the first union type is
null:{"name":"VERSION","type":["null","string"],"default":"0"}To resolve this error, use one of the following approaches:
- Set the default to
nullto match the first union type:{"name": "VERSION", "type": ["null", "string"], "default": null} - Reorder the union types so that
stringis first. The default"0"is then valid:{"name": "VERSION", "type": ["string", "null"], "default": "0"}
- Set the default to
