1. 原始数据
hive> select * from word;
OK
1 MSN
10 QQ
100 Gtalk
1000 Skype
2. 创建avro格式的数据表
hive> CREATE TABLE avro_table(age INT, name STRING)STORED AS AVRO;
3. 数据表的描述
hive> describe avro_table;
OK
age int from deserializer
name string from deserializer
Time taken: 0.154 seconds, Fetched: 2 row(s)
4. 插入数据
hive> INSERT OVERWRITE TABLE avro_table SELECT * FROM word;
5. 查询
hive> select * from avro_table;
OK
1 MSN
10 QQ
100 Gtalk
1000 Skype
6. HDFS上文件的内容(avro二进制格式)
Objavro.schema?{"type":"record","name":"avro_table","namespace":"default","fields":[{"name":"age","type":["null","int"],"doc":"\u0000","default":null},{"name":"name","type":["null","string"],"default":null}]} 9?$-侭蹈艉{3!
T
MSN QQ ?Gtalk ?Skype 9?$-侭蹈艉{3!
7.参考
https://cwiki.apache.org/confluence/display/Hive/AvroSerDe

本文介绍了如何在Hive中读写Avro格式的数据,包括创建Avro数据表、插入数据、查询及查看HDFS上的Avro二进制文件内容,详细阐述了Hive与Avro的集成使用。
6176

被折叠的 条评论
为什么被折叠?



