概念
- Hive在加载数据时,会按照一定的规律,逐个逐个的加载数据,因此在建表的时候要设定数据的分割规律
字段分隔符
- 在我们的数据分布是如下情况是可以使用字段分隔符来进行分割
字段张三,男,19
create table StuInfo(
name string,
gender string,
age int
)
row format delimited fields terminated by ',';
集合分隔符
字段中国,北京:上海:广州:深圳
create table city(
country string,
city string
)
row format delimited fields terminated by ','
collection items by ':';
KV分隔符
字段张三,唱歌:非常喜欢-跳舞:喜欢-游泳:一般般
create table student
(id int,name string,
hobby map<string,string>
)
row format delimited fields terminated by ‘,’
collection items terminated ‘-’
map keys terminated by ‘;’;
本文介绍了Hive在建表时如何设置字段分隔符、集合分隔符和KV分隔符,以便正确解析和加载数据。例如,字段分隔符用于分割如'张三,男,19'这样的数据,集合分隔符用于处理如'中国,北京:上海:广州:深圳'的城市列表,而KV分隔符则用于解析如'张三,唱歌:非常喜欢-跳舞:喜欢-游泳:一般般'的爱好信息。通过这些设置,可以有效地组织和查询大规模数据。
8453

被折叠的 条评论
为什么被折叠?



