hive 分隔符

aomika 2013-06-19 09:11:40

> CREATE TABLE IF NOT EXISTS testdb2.employees (
> name STRING COMMENT 'Employee name',
> salary FLOAT COMMENT 'Employee salary',
> subordinates ARRAY<STRING> COMMENT 'Names of subordinates',
> deductions MAP<STRING, FLOAT>
> COMMENT 'Keys are deductions names, values are percentages',
> address STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>
> COMMENT 'Home address')
> COMMENT 'Description of the table'
> TBLPROPERTIES ('creator'='me', 'created_at'='2012-01-02 10:00:00');
OK
Time taken: 0.132 seconds


> load data local inpath '/tmp/zong'
> overwrite into table employees;
Copying data from file:/tmp/zong
Copying file: file:/tmp/zong/hive_random_name.txt
Loading data to table testdb2.employees
Deleted hdfs://tkpcjk01-10:8020/user/hive/warehouse/testdb2.db/employees
OK
Time taken: 1.247 seconds


目录/tmp/zong 下只有一个文件,里面有三行文本:
[root@tkpcjk01-11 zong]# cat /tmp/zong/hive_random_name.txt
Mary Smith^A80000.0^ABill King^AFederal Taxes^C.2^BState Taxes^C.05^BInsurance^C.1^A100 Ontario St.^BChicago^BIL^B60601
Todd Jones^A70000.0^AFederal Taxes^C.15^BState Taxes^C.03^BInsurance^C.1^A200 Chicago Ave.^BOak Park^BIL^B60700
Bill King^A60000.0^AFederal Taxes^C.15^BState Taxes^C.03^BInsurance^C.1^A300 Obscure Dr.^BObscuria^BIL^B60100

加载到employee表中后,怎么三行记录都跑到 表中的 name 列了
> select * from employees;
OK
name salary subordinates deductions address
Mary Smith^A80000.0^ABill King^AFederal Taxes^C.2^BState Taxes^C.05^BInsurance^C.1^A100 Ontario St.^BChicago^BIL^B60601 NULL null null null
Todd Jones^A70000.0^AFederal Taxes^C.15^BState Taxes^C.03^BInsurance^C.1^A200 Chicago Ave.^BOak Park^BIL^B60700 NULL null null null
Bill King^A60000.0^AFederal Taxes^C.15^BState Taxes^C.03^BInsurance^C.1^A300 Obscure Dr.^BObscuria^BIL^B60100 NULL null null null
Time taken: 0.337 seconds

...全文
408 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
那闯 2013-06-20
  • 打赏
  • 举报
回复
row format delimited fields terminated by '\t' 将分隔符修改成 tab试试, 另外, 再确定一下你的ctrl+A没问题吧。
r6 2013-06-20
  • 打赏
  • 举报
回复
hive默认的分隔符是‘\001’试一试

20,808

社区成员

发帖
与我相关
我的任务
社区描述
Hadoop生态大数据交流社区,致力于有Hadoop,hive,Spark,Hbase,Flink,ClickHouse,Kafka,数据仓库,大数据集群运维技术分享和交流等。致力于收集优质的博客
社区管理员
  • 分布式计算/Hadoop社区
  • 涤生大数据
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧