作者:Syn良子 出处:http://www.cnblogs.com/cssdongl 转载请注明出处
有时候用hive读取外表数据时,比如csv这种类型的,需要跳过行首或者行尾一些和数据无关的或者自动生成的多余信息,这里可以用属性设置来实现,快速mark下,建表的时候设置如下
Create external
table testtable (name string, message string) row format delimited fields terminated
by '\t' lines terminated
by '\n' location
'/user/file.csv' tblproperties ("skip.header.line.
count"
="
1", "skip.footer.line.
count"
="
2");
对,就是上面sql中tblproperties的2个属性
“skip.heaer.line.count” 跳过文件行首多少行
“skip.footer.line.count”跳过文件行尾多少行
注意,这个属性的功能是hive0.13以后的都可以支持
参考资料:
https://issues.apache.org/jira/browse/HIVE-5795