作者: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以后的都可以支持
參考資料: