0
我現在開發的系統的任務是從卡夫卡使用數據並將其放入配置單元中。由於該表具有「日」分區,所以該分區在hdfs上的位置將爲/root/tableLocation/day=20161110/adfadfaaf.avro
。我可以使用java api修改Hive分區位置嗎?
但是,這個位置不能滿足我的requirement.I要將此位置更改爲/root/tableLocation/20161110/adfadfaaf.avro .
我使用的API就是Apache蜂巢metastore.Demo代碼時,我創建表是這樣的:
Table table = new Table(database, tableName);
table.setTableType(TableType.EXTERNAL_TABLE);
table.getParameters().put("EXTERNAL", "TRUE");
String tablePath = FileUtils.hiveDirectoryName(url, topicsDir, tableName);
table.setDataLocation(new Path(tablePath));
table.setSerializationLib(avroSerde);
try {
table.setInputFormatClass(avroInputFormat);
table.setOutputFormatClass(avroOutputFormat);
} catch (HiveException e) {
throw new HiveMetaStoreException("Cannot find input/output format:", e);
}
List<FieldSchema> columns = HiveSchemaConverter.convertSchema(schema);
table.setFields(columns);
table.setPartCols(partitioner.partitionFields());
從代碼中我可以設置表的位置, 但我的問題是,有沒有辦法設置分區的位置?
我認爲不,因爲這個信息應該是元數據的一部分... –