温馨提示×

温馨提示×

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

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

Hive数据类型有哪些

发布时间:2021-12-10 14:05:53 来源:亿速云 阅读:180 作者:小新 栏目:大数据

这篇文章将为大家详细讲解有关Hive数据类型有哪些,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

hive 目前支持的数据类型如下:

-- 数值类型 Numeric Types
TINYINT (1-byte signed integer, from -128 to 127)
SMALLINT (2-byte signed integer, from -32,768 to 32,767)
INT/INTEGER (4-byte signed integer, from -2,147,483,648 to 2,147,483,647)
BIGINT (8-byte signed integer, from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
FLOAT (4-byte single precision floating point number)
DOUBLE (8-byte double precision floating point number)
DOUBLE PRECISION (alias for DOUBLE, only available starting with Hive 2.2.0)
DECIMAL
Introduced in Hive 0.11.0 with a precision of 38 digits
Hive 0.13.0 introduced user-definable precision and scale
NUMERIC (same as DECIMAL, starting with Hive 3.0.0)

--日期/时间类型 Date/Time Types
TIMESTAMP (Note: Only available starting with Hive 0.8.0)
DATE (Note: Only available starting with Hive 0.12.0)
INTERVAL (Note: Only available starting with Hive 1.2.0)

--字符类型 String Types
STRING
VARCHAR (Note: Only available starting with Hive 0.12.0)
CHAR (Note: Only available starting with Hive 0.13.0)

Misc Types
BOOLEAN
BINARY (Note: Only available starting with Hive 0.8.0)

--复杂类型 Complex Types
arrays: ARRAY<data_type> (Note: negative values and non-constant expressions are allowed as of Hive 0.14.)
maps: MAP<primitive_type, data_type> (Note: negative values and non-constant expressions are allowed as of Hive 0.14.)
structs: STRUCT<col_name : data_type [COMMENT col_comment], ...>
union: UNIONTYPE<data_type, data_type, ...> (Note: Only available starting with Hive 0.7.0.)

例子:

1)Array数组
数据类型相同的元素集合。

hive>create table student 
(sid int, 
sname string, 
grade array<float>); 
其中array代表各科成绩,比如:
{1,YY,[80,100,90]}

2)Map
key和value对:

hive>create table student2 
(sid int, 
sname string, 
grade map<string,float>); 
其中map指的是学科对应的成绩,比如:
{1,yy,<'English',90>}
上面的array和map可以组合起来使用,一个人的各科成绩:

hive> create table student3 
(sid int, 
sname string, 
grades array<map<string,float>>); 
{1,'yy',[<'English',80>,<'English3',90>]}

3)struct
结构体:

hive>create table student4 
(sid int, 
info struct<name:string,age:int,sex:string>); 
比如:
{1,{'yy',20,'male'}}

关于“Hive数据类型有哪些”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

向AI问一下细节

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

AI