[英]Processing Multiple AVRO (avsc files) which are in different directory and refer each other using python (fastavro)
I have two avsc files in different directories -我在不同的目录中有两个 avsc 文件 -
1. com.company.model.AddressRecord.avsc
2. com.company.model.Customer.avsc
Here is address file这是地址文件
{
"type": "record",
"namespace": "com.company.model",
"name": "AddressRecord",
"fields": [
{
"name": "streetaddress",
"type": "string"
},
{
"name": "city",
"type": "string"
},
{
"name": "state",
"type": "string"
},
{
"name": "zip",
"type": "string"
}
]
}
here is customer file which is a parent (top level) schema这是客户文件,它是父(顶级)架构
{
"namespace": "com.company.model",
"type": "record",
"name": "Customer",
"fields": [
{
"name": "firstname",
"type": "string"
},
{
"name": "lastname",
"type": "string"
},
{
"name": "email",
"type": "string"
},
{
"name": "phone",
"type": "string"
},
{
"name": "address",
"type": {
"type": "array",
"items": "com.company.model.AddressRecord"
}
}
]
}
I am able to load the files using fastavro when both files are in same directory当两个文件都在同一目录中时,我可以使用 fastavro 加载文件
fastavro.schema.load_schema('com.company.model.Customer.avsc')
But it does not work when both avsc files are in different directories.但是当两个 avsc 文件都在不同的目录中时它不起作用。 What changes I need to do in the files so that fast avro can load the schema if both avsc files are in different direcotry如果两个 avsc 文件都在不同的目录中,我需要对文件进行哪些更改,以便快速 avro 可以加载架构
The documentation for load_schema
says that it only works for files in the same directory. load_schema
的文档说它只适用于同一目录中的文件。 It's not currently possible to do what you want.目前无法执行您想要的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.