Can I split an Apache Avro schema across multiple files?

前端 未结 6 1494
青春惊慌失措
青春惊慌失措 2020-12-24 12:43

I can do,

{
    \"type\": \"record\",
    \"name\": \"Foo\",
    \"fields\": [
        {\"name\": \"bar\", \"type\": {
            \"type\": \"record\",
             


        
6条回答
  •  滥情空心
    2020-12-24 12:48

    I assume, your motivation is (as my own) structuring your schema definition and avoiding copy&paste-errors.

    To achieve that, you can also use Avro IDL. It allows to define avro schemas on a higher level. Reusing types is possible within the same file and also across multiple files.

    To generate the .avsc-files run

    $ java -jar avro-tools-1.7.7.jar idl2schemata my-protocol.avdl
    

    The resulting .avsc-files will look pretty much the same as your initial example, but as they are generated from the .avdl you'll not get lost in the verbose json-format.

提交回复
热议问题