使用avro-tools获取Avro文件的Schema
代码语言:txt
复制avro-tools getschema hdfs://localhost:9000//user/hive/warehouse/retail_stage.db/orders/part-m-00000.avro >~/orders.avsc
将Avro文件的Schema文件上传到HDFS
代码语言:txt
复制hdfs dfs -put orders.avsc /user/hive/warehouse/avro/schema/orders/
创建Hive表
代码语言:txt
复制create external table retail_stage.orders_sqoop
location '/user/hive/warehouse/retail_stage.db/orders'
stored as avro
//这里填写avro文件的schema文件
tblproperties('avro.schema.url'='hdfs://localhost:9000/user/hive/warehouse/avro/schema/orders/orders.avsc')
从表中查询数据