本文整理汇总了Java中org.apache.hadoop.hive.metastore.api.Table.setPartitionKeys方法的典型用法代码示例。如果您正苦于以下问题:Java Table.setPartitionKeys方法的具体用法?Java Table.setPartitionKeys怎么用?Java Table.setPartitionKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.metastore.api.Table
的用法示例。
在下文中一共展示了Table.setPartitionKeys方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPartitionedTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private Table createPartitionedTable(String databaseName, String tableName) throws Exception {
Table table = new Table();
table.setDbName(DATABASE);
table.setTableName(tableName);
table.setPartitionKeys(Arrays.asList(new FieldSchema("partcol", "int", null)));
table.setSd(new StorageDescriptor());
table.getSd().setCols(Arrays.asList(new FieldSchema("id", "int", null), new FieldSchema("name", "string", null)));
table.getSd().setInputFormat("org.apache.hadoop.mapred.TextInputFormat");
table.getSd().setOutputFormat("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat");
table.getSd().setSerdeInfo(new SerDeInfo());
table.getSd().getSerdeInfo().setSerializationLib("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe");
HiveMetaStoreClient client = server.newClient();
client.createTable(table);
client.close();
return table;
}
示例2: createPartitionedTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
static Table createPartitionedTable(HiveMetaStoreClient metaStoreClient, String database, String table, File location)
throws Exception {
Table hiveTable = new Table();
hiveTable.setDbName(database);
hiveTable.setTableName(table);
hiveTable.setTableType(TableType.EXTERNAL_TABLE.name());
hiveTable.putToParameters("EXTERNAL", "TRUE");
hiveTable.setPartitionKeys(PARTITION_COLUMNS);
StorageDescriptor sd = new StorageDescriptor();
sd.setCols(DATA_COLUMNS);
sd.setLocation(location.toURI().toString());
sd.setParameters(new HashMap<String, String>());
sd.setSerdeInfo(new SerDeInfo());
hiveTable.setSd(sd);
metaStoreClient.createTable(hiveTable);
return hiveTable;
}
示例3: newTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private Table newTable() {
Table table = new Table();
table.setDbName(DB_NAME);
table.setTableName(TABLE_NAME);
table.setTableType(TableType.EXTERNAL_TABLE.name());
StorageDescriptor sd = new StorageDescriptor();
sd.setLocation(tableLocation);
table.setSd(sd);
HashMap<String, String> parameters = new HashMap<>();
parameters.put(StatsSetupConst.ROW_COUNT, "1");
table.setParameters(parameters);
table.setPartitionKeys(PARTITIONS);
return table;
}
示例4: createView
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private static Table createView(
HiveMetaStoreClient metaStoreClient,
String database,
String view,
String table,
List<FieldSchema> partitionCols)
throws TException {
Table hiveView = new Table();
hiveView.setDbName(database);
hiveView.setTableName(view);
hiveView.setTableType(TableType.VIRTUAL_VIEW.name());
hiveView.setViewOriginalText(hql(database, table));
hiveView.setViewExpandedText(expandHql(database, table, DATA_COLUMNS, partitionCols));
hiveView.setPartitionKeys(partitionCols);
StorageDescriptor sd = new StorageDescriptor();
sd.setCols(DATA_COLUMNS);
sd.setParameters(new HashMap<String, String>());
sd.setSerdeInfo(new SerDeInfo());
hiveView.setSd(sd);
metaStoreClient.createTable(hiveView);
return hiveView;
}
示例5: createTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private void createTable(File sourceTableUri) throws Exception {
File partitionEurope = new File(sourceTableUri, "local_date=2000-01-01");
File partitionUk = new File(partitionEurope, "local_hour=0");
File dataFileUk = new File(partitionUk, PART_00000);
FileUtils.writeStringToFile(dataFileUk, "1\tadam\tlondon\n2\tsusan\tglasgow\n");
File partitionAsia = new File(sourceTableUri, "local_date=2000-01-02");
File partitionChina = new File(partitionAsia, "local_hour=0");
File dataFileChina = new File(partitionChina, PART_00000);
String data = "1\tchun\tbeijing\n2\tshanghai\tmilan\n";
FileUtils.writeStringToFile(dataFileChina, data);
HiveMetaStoreClient sourceClient = sourceCatalog.client();
Table source = new Table();
source.setDbName(DATABASE);
source.setTableName(TABLE);
source.setTableType(TableType.EXTERNAL_TABLE.name());
source.setParameters(new HashMap<String, String>());
List<FieldSchema> partitionColumns = Arrays.asList(new FieldSchema("local_date", "string", ""),
new FieldSchema("local_hour", "string", ""));
source.setPartitionKeys(partitionColumns);
List<FieldSchema> dataColumns = Arrays.asList(new FieldSchema("id", "bigint", ""),
new FieldSchema("name", "string", ""), new FieldSchema("city", "tinyint", ""));
StorageDescriptor sd = new StorageDescriptor();
sd.setCols(dataColumns);
sd.setLocation(sourceTableUri.toURI().toString());
sd.setParameters(new HashMap<String, String>());
sd.setSerdeInfo(new SerDeInfo());
source.setSd(sd);
sourceClient.createTable(source);
LOG.info(">>>> Partitions added: {}",
+sourceClient.add_partitions(Arrays.asList(newPartition(sd, Arrays.asList("2000-01-01", "0"), partitionUk),
newPartition(sd, Arrays.asList("2000-01-02", "0"), partitionChina))));
}
示例6: newTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
public static Table newTable(String name, String dbName, List<FieldSchema> partitionKeys, StorageDescriptor sd) {
Table table = new Table();
table.setTableName(name);
table.setDbName(dbName);
table.setSd(sd);
table.setPartitionKeys(partitionKeys);
table.setTableType(TableType.EXTERNAL_TABLE.name());
table.setParameters(new HashMap<String, String>());
return table;
}
示例7: createPartitionedTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
public static Table createPartitionedTable(
HiveMetaStoreClient metaStoreClient,
String database,
String table,
URI location)
throws Exception {
Table hiveTable = new Table();
hiveTable.setDbName(database);
hiveTable.setTableName(table);
hiveTable.setTableType(TableType.EXTERNAL_TABLE.name());
hiveTable.putToParameters("EXTERNAL", "TRUE");
hiveTable.setPartitionKeys(PARTITION_COLUMNS);
StorageDescriptor sd = new StorageDescriptor();
sd.setCols(DATA_COLUMNS);
sd.setLocation(location.toString());
sd.setParameters(new HashMap<String, String>());
sd.setInputFormat(TextInputFormat.class.getName());
sd.setOutputFormat(TextOutputFormat.class.getName());
sd.setSerdeInfo(new SerDeInfo());
sd.getSerdeInfo().setSerializationLib("org.apache.hadoop.hive.serde2.OpenCSVSerde");
hiveTable.setSd(sd);
metaStoreClient.createTable(hiveTable);
ColumnStatisticsDesc statsDesc = new ColumnStatisticsDesc(true, database, table);
ColumnStatisticsData statsData = new ColumnStatisticsData(_Fields.LONG_STATS, new LongColumnStatsData(1L, 2L));
ColumnStatisticsObj cso1 = new ColumnStatisticsObj("id", "bigint", statsData);
List<ColumnStatisticsObj> statsObj = Collections.singletonList(cso1);
metaStoreClient.updateTableColumnStatistics(new ColumnStatistics(statsDesc, statsObj));
return hiveTable;
}
示例8: newTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private static Table newTable(String databaseName, String tableName, String location) {
Table table = new Table();
table.setDbName(databaseName);
table.setTableName(tableName);
table.setParameters(new HashMap<String, String>());
table.setPartitionKeys(Arrays.asList(new FieldSchema("a", "string", null)));
StorageDescriptor sd = new StorageDescriptor();
sd.setLocation(location);
table.setSd(sd);
return table;
}
示例9: createSourceTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private void createSourceTable() throws Exception {
File partitionEurope = new File(sourceTableUri, "local_date=2000-01-01");
File partitionUk = new File(partitionEurope, "local_hour=0");
File dataFileUk = new File(partitionUk, PART_00000);
FileUtils.writeStringToFile(dataFileUk, "1\tadam\tlondon\n2\tsusan\tglasgow\n");
File partitionAsia = new File(sourceTableUri, "local_date=2000-01-02");
File partitionChina = new File(partitionAsia, "local_hour=0");
File dataFileChina = new File(partitionChina, PART_00000);
String data = "1\tchun\tbeijing\n2\tshanghai\tmilan\n";
FileUtils.writeStringToFile(dataFileChina, data);
HiveMetaStoreClient sourceClient = catalog.client();
Table source = new Table();
source.setDbName(DATABASE);
source.setTableName(SOURCE_TABLE);
source.setTableType(TableType.EXTERNAL_TABLE.name());
Map<String, String> parameters = new HashMap<>();
parameters.put("comment", "comment source");
source.setParameters(parameters);
List<FieldSchema> partitionColumns = Arrays.asList(new FieldSchema("local_date", "string", ""),
new FieldSchema("local_hour", "string", ""));
source.setPartitionKeys(partitionColumns);
List<FieldSchema> dataColumns = Arrays.asList(new FieldSchema("id", "bigint", ""),
new FieldSchema("name", "string", ""), new FieldSchema("city", "string", ""));
StorageDescriptor sd = new StorageDescriptor();
sd.setCols(dataColumns);
sd.setLocation(sourceTableUri.toURI().toString());
sd.setParameters(new HashMap<String, String>());
sd.setSerdeInfo(new SerDeInfo());
source.setSd(sd);
sourceClient.createTable(source);
LOG.info(">>>> Partitions added: {}",
+sourceClient
.add_partitions(Arrays.asList(newPartition(SOURCE_TABLE, sd, Arrays.asList("2000-01-01", "0"), partitionUk),
newPartition(SOURCE_TABLE, sd, Arrays.asList("2000-01-02", "0"), partitionChina))));
}
示例10: createReplicaTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private void createReplicaTable() throws Exception {
File partitionEurope = new File(replicaTableUri, "local_date=2000-01-01");
File partitionUk = new File(partitionEurope, "local_hour=0");
File dataFileUk = new File(partitionUk, PART_00000);
FileUtils.writeStringToFile(dataFileUk, "1\tadam\tlondon\tuk\n2\tsusan\tglasgow\tuk\n");
File partitionAsia = new File(replicaTableUri, "local_date=2000-01-02");
File partitionChina = new File(partitionAsia, "local_hour=0");
File dataFileChina = new File(partitionChina, PART_00000);
String data = "1\tchun\tbeijing\tchina\n2\tshanghai\tmilan\titaly\n";
FileUtils.writeStringToFile(dataFileChina, data);
HiveMetaStoreClient replicaClient = catalog.client();
Table replica = new Table();
replica.setDbName(DATABASE);
replica.setTableName(REPLICA_TABLE);
replica.setTableType(TableType.EXTERNAL_TABLE.name());
Map<String, String> parameters = new HashMap<>();
parameters.put("comment", "comment replica");
replica.setParameters(parameters);
List<FieldSchema> partitionColumns = Arrays.asList(new FieldSchema("local_date", "string", ""),
new FieldSchema("local_hour", "string", ""));
replica.setPartitionKeys(partitionColumns);
List<FieldSchema> dataColumns = Arrays.asList(new FieldSchema("id", "bigint", ""),
new FieldSchema("name", "string", ""), new FieldSchema("city", "string", ""),
new FieldSchema("country", "string", ""));
StorageDescriptor sd = new StorageDescriptor();
sd.setCols(dataColumns);
sd.setLocation(replicaTableUri.toURI().toString());
sd.setParameters(new HashMap<String, String>());
sd.setSerdeInfo(new SerDeInfo());
replica.setSd(sd);
replicaClient.createTable(replica);
LOG.info(">>>> Partitions added: {}",
+replicaClient.add_partitions(
Arrays.asList(newPartition(REPLICA_TABLE, sd, Arrays.asList("2000-01-01", "0"), partitionUk),
newPartition(REPLICA_TABLE, sd, Arrays.asList("2000-01-02", "0"), partitionChina))));
}
示例11: createTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
private void createTable(
String databaseName,
String tableName,
File tableLocation,
String sourceTable,
String sourceLocation,
boolean addChecksum)
throws Exception {
File partition0 = createPartitionData("part=0", tableLocation, Arrays.asList("1\tadam", "2\tsusan"));
File partition1 = createPartitionData("part=1", tableLocation, Arrays.asList("3\tchun", "4\tkim"));
Table table = new Table();
table.setDbName(databaseName);
table.setTableName(tableName);
table.setTableType(TableType.EXTERNAL_TABLE.name());
table.setParameters(new HashMap<String, String>());
if (sourceTable != null) {
table.getParameters().put(CircusTrainTableParameter.SOURCE_TABLE.parameterName(), sourceTable);
}
if (sourceLocation != null) {
table.getParameters().put(CircusTrainTableParameter.SOURCE_LOCATION.parameterName(), sourceLocation);
}
List<FieldSchema> partitionColumns = Arrays.asList(PARTITION_COL);
table.setPartitionKeys(partitionColumns);
List<FieldSchema> dataColumns = Arrays.asList(FOO_COL, BAR_COL);
StorageDescriptor sd = new StorageDescriptor();
sd.setCols(dataColumns);
sd.setLocation(tableLocation.toURI().toString());
sd.setParameters(new HashMap<String, String>());
sd.setSerdeInfo(new SerDeInfo());
table.setSd(sd);
HiveMetaStoreClient client = catalog.client();
client.createTable(table);
LOG.info(">>>> Partitions added: {}",
+client.add_partitions(Arrays.asList(
newPartition(databaseName, tableName, sd, Arrays.asList("0"), partition0, sourceTable,
sourceLocation + "part=0", addChecksum),
newPartition(databaseName, tableName, sd, Arrays.asList("1"), partition1, sourceTable,
sourceLocation + "part=1", addChecksum))));
}