txt导入到hive

2018-12-05  本文已影响0人  cure_py
  1. 在自己电脑上excel里录入内容


  2. 复制去txt
    在notepad++ 里查看一下所有符号,保持一致。有时候 --> 会变成 .....


  3. 上传至linux 自己账号下,俗称本地。没有上传就 vim a.txt这种,复制粘贴进去

rz -y
  1. pwd获取 txt的路径
  2. hive中创建表
CREATE TABLE `vip_mid.paypoint_tmp2`(
`plat` string, 
`channel` string, 
`position` string, 
`paypoint` string, 
`refer_name` string)
row format delimited fields terminated by '\t' 
--lines terminated by '\n' 
stored as textfile;
  1. load进hive
load data local inpath '/home/zhangzhiyu/cure/a.txt' overwrite into table vip_mid.paypoint_tmp2;

语句中要有 stored as textfile 否则会报下面的错误
报错:
Failed with exception Wrong file format. Please check the file's format.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask

  1. 插入最终的表
insert into vip_mid.paypoint_tmp select * from vip_mid.paypoint_tmp2;
上一篇 下一篇

猜你喜欢

热点阅读