简体   繁体   English

处理不同目录中的多个AVRO(avsc文件)并使用python(fastavro)相互引用

[英]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.

相关问题 使用 python (fastavro) 解析多个相互引用的 AVRO (avsc 文件) - Parsing Multiple AVRO (avsc files) which refer each other using python (fastavro) 使用 Python 将 XSD(XML Schema)转换为 AVSC(Avro Schema) - Convert XSD (XML Schema) to AVSC (Avro Schema) using Python 使用 fastavro 从 Kafka 反序列化 Avro - Avro deserialization from Kafka using fastavro python:引用不同的pip目录 - python : refer to different pip directory 相互引用的python类 - python classes that refer to each other 将多个 json 文件附加在一起并使用 Python 输出 1 个 Avro 文件 - append multiple json files together and ouptut 1 Avro file using Python Processing 3.0.1中用于Python模式的文件位于哪个目录中? - In which directory are the files for Python mode in Processing 3.0.1 are living? 每次使用pandas和python处理多个文件时,从txt文件中读取单个变量 - Read single varible from txt file each time processing multiple files using pandas and python 处理 Python 项目文件夹的最佳方法是什么,该文件夹包含多个 Python 脚本,它们的要求彼此不同? - What is the best way to deal with a Python project folder which has multiple Python scripts which have different requirements than each other? 无法读回使用python fastavro包创建的微小avro文件 - Can't read back tiny avro file created with python fastavro package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM