温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

hive的数据类型

发布时间:2020-07-29 07:00:02 来源:网络 阅读:943 作者:原生zzy 栏目:大数据

1.基本数据类型

因为hive也是java语言编写的,所以他的基本数据类型和java的大致相同:
hive的数据类型

2.基本数据类型

(1)array(数组)

特点:个数可以不相同,但是类型相同
例:以family表(name string familes array<string>)为例:

#建表语句:
create table t_family (name string, familes array<string>) row format delimited fields terminated by '\t' collection items  terminated  by ',';
#查询
select * from t_family;

hive的数据类型

#查询数组中的某一个
select  name, familes[0] from t_family; 

hive的数据类型

(2)map ----映射

特点:key-value 可以不相同,个数也可以不同
数据格式:zs age:28,salary:20000,address:beijing

#建表语句:
create table user_info(name string,info map<string,string>) row format delimieted fields terminated by '\t' collection items terminated by ',' map keys terminated by ':'
#查询语句
select * from user_info;

hive的数据类型

#查询具体的map的key的值
select name ,info['age'],info['salary']  from user_info ;

hive的数据类型

(3)struct类型 ----对象

特点:个数相同,类型相同
例:
以stu(name ,info)为例
数据格式:zss 26,123456,shanghai,695

#建表语句:
`create table stu_info(name string, info struct<age:int,id:string,address:string,score:double>) row format delimted fields terminated by '\t' collection items terminated by ','`
#查询语句
select * from stu_info;

hive的数据类型

#具体的对象属性查询
select name,info.address from stu_info;

hive的数据类型

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI