hive(2)数据类型和文件格式

基本的数据类型

Hive支持关系型数据中大多数基本的数据类型,同时也支持关系型数据库中很少出现的三种集合数据类型。

集合数据类型

Hive中的列支持使用struct、map、array集合数据类型,下表中的语法示例是调用的内置函数。

例如:创建表:

hive>create table emp(name string, salary float, subordinates array<string>, deductions map<string,float>, address struct<stree:string, city:string, state:string, zip:int>);

 

文本文件数据编码

下图表示Hive中默认的记录和字段分隔符

例如:创建表的时候,指定分隔符(示例中的分隔符都是默认的分隔符,如果想要指定其他的分隔符,可以重新设置。)

hive> create table emp(name string, salary float, subordinates array<string>, deductions map<string,float>, address struct<stree:string, city:string, state:string, zip:int>)
row format delimited
   fields terminated by '\001'
collection items terminated by '\002'
map keys terminated by '\003'
lines terminated by '\n'
stored as textfile;



说明:

row format delimited(行格式化分隔符)关键字需要在其他字句(除stored as...)之前
fields terminated by:字段终止,指定字段的分隔符
collection items terminated by:集合元素间的分隔符
map keys terminated by:map键值之间的分隔符
lines terminated by:指定行分隔符
lines terminated by和stored as 不需要row format delimited关键字。

 

posted @ 2019-06-20 16:00  北漂-boy  阅读(438)  评论(0编辑  收藏  举报