20,808
社区成员
发帖
与我相关
我的任务
分享
> 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