2016-11-10 61 views
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()); 

從代碼中我可以設置表的位置, 但我的問題是,有沒有辦法設置分區的位置?

+0

我認爲不,因爲這個信息應該是元數據的一部分... –

回答

0

in hive and hdfs,分區本質上是表目錄下的子目錄。方式配置單元通過如 <col name>=<partition value> 等結構識別分區如果您將該子目錄名稱更改爲<partition value>,則它不會被配置單元識別爲分區。

相關問題