如何将如下所示的简单 python 类转换为 avro 模式?
class Testo(SQLModel):
name: str
mea: int
这是
Testo.schema()
输出
{
"title": "Testo",
"type": "object",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"mea": {
"title": "Mea",
"type": "integer"
}
},
"required": [
"name",
"mea"
]
}
从这里我想创建一个 Avro 记录。这可以在 konbert.com 上在线转换(选择 JSON 到 AVRO 模式),它会产生下面的 Avro 模式。 (尽管名称字段应该是“Testo”而不是“Record”,但都有效。)
{
"type": "record",
"name": "Record",
"fields": [
{
"name": "title",
"type": "string"
},
{
"name": "type",
"type": "string"
},
{
"name": "properties.name.title",
"type": "string"
},
{
"name": "properties.name.type",
"type": "string"
},
{
"name": "properties.mea.title",
"type": "string"
},
{
"name": "properties.mea.type",
"type": "string"
},
{
"name": "required",
"type": {
"type": "array",
"items": "string"
}
}
]
}
无论如何,如果他们能做到,肯定有办法用当前的 python 库转换它。哪个库可以进行有效转换(以及复杂的 pyhton 模型/类?