概述
MAP:MAP包含key->value键值对,可以通过key来访问元素。比如”userlist”是一个map类型,其中username是key,password是value;那么我们可以通过userlist['username']来得到这个用户对应的password;
操作实例
1、创建表
hive> create table map_test(id string,perf map)
> row format delimited fields terminated by "\t"
> collection items terminated by ','
> map keys terminated by ':'
> ;
与struct的区别:
create table map_test(id string,perf map)
create table student_test(id int,infostruct)
------------
再建一张map_test2,测试map字段名不一致会如何
hive> create table map_test2(id string,perf map)
> row format delimited fields terminated by "\t"
> collection items terminated by ','
> map keys terminated by ':'
> ;
2、准备文件
--------