默认hive的字段分隔符(field delimiter)可以通过row terminated或者重写InputFormat来改写,但是对于列分隔符这样做就不行,我是这么做的:
@Override
public boolean next(LongWritable key, Text value) throws IOException {
while (reader.next(key, text)) {
String strReplace = text.toString().toLowerCase()
.replaceAll("\u0002", "\n");
Text txtReplace = new Text();
txtReplace.set(strReplace);
value.set(txtReplace.getBytes(), 0, txtReplace.getLength());
return true;
}
return false;
}
重写inputformat放到hive的lib里不行,如果是这样改变字段分隔符是可以的,有没有办法指定列分隔符? 因为我文件里的数据都是通过'\u0002'来分割每行数据的,先谢谢各位大神了!