溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

hive的數(shù)據(jù)類型

發(fā)布時間:2020-07-29 07:00:02 來源:網(wǎng)絡(luò) 閱讀:953 作者:原生zzy 欄目:大數(shù)據(jù)

1.基本數(shù)據(jù)類型

因為hive也是java語言編寫的,所以他的基本數(shù)據(jù)類型和java的大致相同:
hive的數(shù)據(jù)類型

2.基本數(shù)據(jù)類型

(1)array(數(shù)組)

特點:個數(shù)可以不相同,但是類型相同
例:以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的數(shù)據(jù)類型

#查詢數(shù)組中的某一個
select  name, familes[0] from t_family; 

hive的數(shù)據(jù)類型

(2)map ----映射

特點:key-value 可以不相同,個數(shù)也可以不同
數(shù)據(jù)格式: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的數(shù)據(jù)類型

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

hive的數(shù)據(jù)類型

(3)struct類型 ----對象

特點:個數(shù)相同,類型相同
例:
以stu(name ,info)為例
數(shù)據(jù)格式: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的數(shù)據(jù)類型

#具體的對象屬性查詢
select name,info.address from stu_info;

hive的數(shù)據(jù)類型

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI