我们能否同时传递模式id和版本以从模式注册表获取模式?我知道这些功能
通过ID获取架构
sr = SchemaRegistryClient('localhost:8081')
my_schema = sr.get_by_id(schema_id=1)
它返回
{'type': 'record', 'name': 'io.confluent.examples.clients.basicavro.Customer', 'fields': [{'name': 'customerId', 'type': 'string'}, {'name': 'firstName', 'type': 'int'}, {'name': 'lastName', 'type': 'string'}, {'name': 'email', 'type': 'string'}, {'name': 'phone', 'type': 'string'}], '__fastavro_parsed': True}
以及
按主题名称获取架构
sr = SchemaRegistryClient('localhost:8081')
my_schema = sr.get_schema(subject='mySubject', version='latest')
它返回
SchemaVersion(subject='mySubject', schema_id=1, schema=<schema_registry.client.schema.AvroSchema object at 0x000001A7271D6C18>, version=1)
在get_schema()中,我可以给出版本,但模式不正确。在get_by_id()中,我获得了正确格式的模式,但无法选择版本
有什么方法可以让我获得模式并选择版本吗?任何帮助都将不胜感激
我认为您的思路是正确的,但是您需要在返回的类中使用字段
相关问题 更多 >
编程相关推荐