Hive 加载数据跳过表头
Hive 加载数据跳过表头
问题
问题描述
hive加载数据时把表头当作数据加载到表中

执行命令
load data inpath "hdfs://node4.co:9000/hotelsparktask3" overwrite into table rawdata;
解决方案
方案一 修改已建的表
alter table rawdata set TBLPROPERTIES ('skip.header.line.count'='1');
方案二 创建表时指定
create table rawdata(
seq string,
hotelname string comment "酒店",
country string comment "国家",
province string comment "省份",
city string comment "城市",
trading_area string comment "商圈",
start string comment "星级",
ywbm string comment "业务部门",
room string comment "房间数",
image string comment "图片数",
score string comment "评分",
comment_num string comment "评论数",
city_avgrealmidnight string comment "城市平均实住间夜",
hotel_order_num string comment "酒店总订单",
hotel_midnight string comment "酒店总间夜",
hotel_realorder string comment "酒店实住订单",
hotel_realmidnight string comment "酒店实住间夜",
hotel_direorder string comment "酒店直销订单",
hotel_diremidnight string comment "酒店直销间夜",
hotel_direrealmidnight string comment "酒店直销实住间夜",
hotel_direnoorder string comment "酒店直销拒单",
hotel_direnoorderrate string comment "酒店直销拒单率",
city_direnoorder string comment "城市直销订单",
city_direnoorderrate string comment "城市直销拒单率",
flag string comment "拒单率是否小于等于直销城市均值"
)
row format delimited
fields terminated by ","
lines terminated by "\n"
TBLPROPERTIES ('skip.header.line.count'='1') stored as textfile;
效果展示

