I have a schema already registered in schema registry, which I was able to do using register()
like this,
from schema_registry.client import SchemaRegistryClient, schema
subject_name = "new-schema"
schema_url = "https://{{ schemaRegistry }}:8081"
sr = SchemaRegistryClient(schema_url)
schema = schema.AvroSchema({
"namespace": "example.avro",
"type": "record",
"name": "user",
"fields": [
{"name": "fname", "type": "string"},
{"name": "favorite_number", "type": "int"}
]
})
my_schema = sr.register(subject_name, schema)
Now I need to update this same subject with a new field, so I will get new schema id, and version = 2
.
updated_schema = schema.AvroSchema({
"namespace": "example.avro",
"type": "record",
"name": "user",
"fields": [
{"name": "fname", "type": "string"},
{"name": "favorite_number", "type": "int"},
{"name": "favorite_food", "type": "string"}
]
})
I tried using sr.register(subject_name, updated_schema)
, it throws error for same subject:
AttributeError: 'ClientError' object has no attribute '_get_object_id'
ClientError: Incompatible Avro schema
Yes this function is to register new schema not to update. I didn't get any update function and I don't know how can I do this. SO how can I update schema? Any help would be appreciated.