标签:hive
hive支持的数据类型路下
TINYINT
(1字节,数据范围: -128
to 127
)SMALLINT
(2字节,数据范围: -32,768
to 32,767
)INT
(4字节,数据范围:-2,147,483,648
to 2,147,483,647
)BIGINT
(8字节,数据范围: -9,223,372,036,854,775,808
to 9,223,372,036,854,775,807
)FLOAT
(4字节, 单精度浮点数)DOUBLE
(8字节,双精度浮点数)DECIMAL
STRING
VARCHAR
(Hive 0.12.0以上支持)CHAR
(Hive 0.13.0以上支持)ARRAY<data_type>
MAP<primitive_type, data_type>
STRUCT<col_name : data_type [COMMENT col_comment], ...>
UNIONTYPE<data_type, data_type, ...>
(Hive 0.7.0以上支持)TINYINT
, SMALLINT
, INT
, BIGINT
)
数值类型默认是int,如果数值超出int的范围,就会被解释为bigint。
数值后面加上后缀表示:
Type |
Postfix |
Example |
---|---|---|
TINYINT |
Y |
100Y |
SMALLINT |
S |
100S |
BIGINT |
L |
100L |
字符串可以用单引号(‘)或双引号(“)。Hive在字符串中使用C-Style的转义。
Varchar types 创建的长度是 ( 1 到 65355), 在字符串中容许使用最大数量的字符. 如果string类型转换成varchar类型, 长度超过了最大值,将会被截断。 字符长度是由字符串所包含的数量决定.
最大固定长度255.
支持传统的unix时间戳,可选的纳秒级精度。
支持的转换:
时间戳被解释是与timezone无关,存储为从UNIX纪元的偏移量。提供便利的UDF和时区转换(to_utc_timestamp,from_utc_timestamp)。
日期值描述一个特定的年/月/日的{ { YYYY - MM - DD } }.
例, DATE ‘2013--01--01‘. Date 类型没有时间.
Date 类型支持的范围是是 0000--01--01 to 9999--12--31, 依赖于原始的Java支持的日期类型.
Date类型能和 Timestamp, String互相转换.
Valid casts to/from Date type |
Result |
---|---|
cast(date as date) |
Same date value |
cast(timestamp as date) |
The year/month/day of the timestamp is determined, based on the local timezone, and returned as a date value. |
cast(string as date) |
If the string is in the form ‘YYYY-MM-DD‘, then a date value corresponding to that year/month/day is returned. If the string value does not match this formate, then NULL is returned. |
cast(date as timestamp) |
A timestamp value is generated corresponding to midnight of the year/month/day of the date value, based on the local timezone. |
cast(date as string) |
The year/month/day represented by the Date is formatted as a string in the form ‘YYYY-MM-DD‘. |
标签:hive
原文地址:http://blog.csdn.net/wind520/article/details/39210067