2016-11-10 98 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>,则它不会被配置单元识别为分区。

相关问题