Generate Avro Schema File and Store in HDFS

老子叫甜甜 提交于 2019-12-24 07:07:42

问题


I'm using avro tools to generate a schema file from an avro file in HDFS and dump it to the Linux file system using this command:

hadoop jar /usr/bin/Avro/avro-tools-1.8.1.jar getschema /dw/hpm/ap_drg/ap_drg.avro > usr/bin/StageSchema/ap_drg.avsc

This works great and gets me the file I need. However; I would like the schema file to be in HDFS and not the Linux file system. How can I change this command to accomplish this? Is there another way I should be doing this?


回答1:


Played around for a bit and finally figured out something that worked:

hadoop jar /usr/bin/Avro/avro-tools-1.8.1.jar getschema /dw/hpm/ap_drg/ap_drg.avro | hadoop fs -put -f - /dw/schemas/hpm/ap_drg/ap_drg.avsc

This will extract an Avro schema from an Avro file on hdfs and write to an Avro schema file in hdfs. The -f will make sure any existing schema file will be overwritten.



来源:https://stackoverflow.com/questions/39667843/generate-avro-schema-file-and-store-in-hdfs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!