本文整理了Java中org.apache.hadoop.hive.metastore.api.Partition.setCatName()
方法的一些代码示例,展示了Partition.setCatName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Partition.setCatName()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.metastore.api.Partition
类名称:Partition
方法名:setCatName
暂无
代码示例来源:origin: apache/hive
/**
* @param new_parts
* @throws InvalidObjectException
* @throws AlreadyExistsException
* @throws MetaException
* @throws TException
* @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#add_partitions(List)
*/
@Override
public int add_partitions(List<Partition> new_parts) throws TException {
if (new_parts == null || new_parts.contains(null)) {
throw new MetaException("Partitions cannot be null.");
}
if (new_parts != null && !new_parts.isEmpty() && !new_parts.get(0).isSetCatName()) {
final String defaultCat = getDefaultCatalog(conf);
new_parts.forEach(p -> p.setCatName(defaultCat));
}
return client.add_partitions(new_parts);
}
代码示例来源:origin: apache/hive
@Override
public void setCatName(String catName) {
partitionSpec.setCatName(catName);
for (Partition partition : partitionSpec.getPartitionList().getPartitions()) {
partition.setCatName(catName);
}
}
代码示例来源:origin: apache/hive
public Partition add_partition(Partition new_part, EnvironmentContext envContext)
throws TException {
if (new_part != null && !new_part.isSetCatName()) {
new_part.setCatName(getDefaultCatalog(conf));
}
Partition p = client.add_partition_with_environment_context(new_part, envContext);
return deepCopy(p);
}
代码示例来源:origin: apache/hive
String defaultCat = getDefaultCatalog(conf);
for (Partition p : parts) {
p.setCatName(defaultCat);
代码示例来源:origin: apache/hive
public Partition build(Configuration conf) throws MetaException {
if (tableName == null) {
throw new MetaException("table name must be provided");
}
if (values == null) throw new MetaException("You must provide partition values");
if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf);
Partition p = new Partition(values, dbName, tableName, createTime, lastAccessTime, buildSd(),
partParams);
p.setCatName(catName);
return p;
}
代码示例来源:origin: apache/hive
@Override
public List<Partition> add_partitions(
List<Partition> parts, boolean ifNotExists, boolean needResults) throws TException {
if (parts == null || parts.contains(null)) {
throw new MetaException("Partitions cannot be null.");
}
if (parts.isEmpty()) {
return needResults ? new ArrayList<>() : null;
}
Partition part = parts.get(0);
// Have to set it for each partition too
if (!part.isSetCatName()) {
final String defaultCat = getDefaultCatalog(conf);
parts.forEach(p -> p.setCatName(defaultCat));
}
AddPartitionsRequest req = new AddPartitionsRequest(
part.getDbName(), part.getTableName(), parts, ifNotExists);
req.setCatName(part.isSetCatName() ? part.getCatName() : getDefaultCatalog(conf));
req.setNeedResult(needResults);
AddPartitionsResult result = client.add_partitions_req(req);
return needResults ? FilterUtils.filterPartitionsIfEnabled(
isClientFilterEnabled, filterHook, result.getPartitions()) : null;
}
代码示例来源:origin: apache/hive
public static Partition createMetaPartitionObject(Table tbl, Map<String, String> partSpec, Path location)
throws MetastoreException {
List<String> pvals = new ArrayList<String>();
for (FieldSchema field : getPartCols(tbl)) {
String val = partSpec.get(field.getName());
if (val == null || val.isEmpty()) {
throw new MetastoreException("partition spec is invalid; field "
+ field.getName() + " does not exist or is empty");
}
pvals.add(val);
}
Partition tpart = new Partition();
tpart.setCatName(tbl.getCatName());
tpart.setDbName(tbl.getDbName());
tpart.setTableName(tbl.getTableName());
tpart.setValues(pvals);
if (!MetaStoreUtils.isView(tbl)) {
tpart.setSd(tbl.getSd().deepCopy());
tpart.getSd().setLocation((location != null) ? location.toString() : null);
}
return tpart;
}
}
代码示例来源:origin: apache/hive
new_part.setCatName(catName);
代码示例来源:origin: apache/hive
private Partition convertToPart(String catName, String dbName, String tblName, MPartition mpart)
throws MetaException {
if (mpart == null) {
return null;
}
Partition p = new Partition(convertList(mpart.getValues()), dbName, tblName,
mpart.getCreateTime(), mpart.getLastAccessTime(),
convertToStorageDescriptor(mpart.getSd(), false), convertMap(mpart.getParameters()));
p.setCatName(catName);
p.setWriteId(mpart.getWriteId());
return p;
}
代码示例来源:origin: apache/hive
@Override
public Partition getCurrent() {
PartitionWithoutSD partWithoutSD = pSpec.getPartitions().get(index);
StorageDescriptor partSD = new StorageDescriptor(pSpec.getSd());
partSD.setLocation(partSD.getLocation() + partWithoutSD.getRelativePath());
Partition p = new Partition(
partWithoutSD.getValues(),
partitionSpecWithSharedSDProxy.partitionSpec.getDbName(),
partitionSpecWithSharedSDProxy.partitionSpec.getTableName(),
partWithoutSD.getCreateTime(),
partWithoutSD.getLastAccessTime(),
partSD,
partWithoutSD.getParameters()
);
p.setCatName(partitionSpecWithSharedSDProxy.partitionSpec.getCatName());
return p;
}
代码示例来源:origin: apache/hive
@Override
public AddPartitionsResult add_partitions_req(AddPartitionsRequest request)
throws TException {
AddPartitionsResult result = new AddPartitionsResult();
if (request.getParts().isEmpty()) {
return result;
}
try {
if (!request.isSetCatName()) {
request.setCatName(getDefaultCatalog(conf));
}
// Make sure all of the partitions have the catalog set as well
request.getParts().forEach(p -> {
if (!p.isSetCatName()) {
p.setCatName(getDefaultCatalog(conf));
}
});
List<Partition> parts = add_partitions_core(getMS(), request.getCatName(), request.getDbName(),
request.getTblName(), request.getParts(), request.isIfNotExists());
if (request.isNeedResult()) {
result.setPartitions(parts);
}
} catch (TException te) {
throw te;
} catch (Exception e) {
throw newMetaException(e);
}
return result;
}
代码示例来源:origin: apache/hive
p.setCatName(DEFAULT_CATALOG_NAME);
objectStore.addPartition(p);
代码示例来源:origin: apache/hive
Map<String, String> transactionalListenerResponses = Collections.emptyMap();
if (!part.isSetCatName()) {
part.setCatName(getDefaultCatalog(conf));
代码示例来源:origin: apache/hive
ptn1.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.addPartition(ptn1);
Partition ptn2 =
new Partition(partVals2, dbName, tblName, 0, 0, sd, new HashMap<>());
ptn2.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.addPartition(ptn2);
代码示例来源:origin: apache/hive
ptn1.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.addPartition(ptn1);
Partition ptn2 =
new Partition(partVals2, dbName, tblName, 0, 0, sd, new HashMap<>());
ptn2.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.addPartition(ptn2);
代码示例来源:origin: apache/hive
List<String> value1 = Arrays.asList("US", "CA");
Partition part1 = new Partition(value1, DB1, TABLE1, 111, 111, sd, partitionParams);
part1.setCatName(DEFAULT_CATALOG_NAME);
objectStore.addPartition(part1);
List<String> value2 = Arrays.asList("US", "MA");
Partition part2 = new Partition(value2, DB1, TABLE1, 222, 222, sd, partitionParams);
part2.setCatName(DEFAULT_CATALOG_NAME);
objectStore.addPartition(part2);
代码示例来源:origin: apache/hive
try {
ms.openTransaction();
part.setCatName(catName);
part.setDbName(dbName);
part.setTableName(tableName);
代码示例来源:origin: apache/hive
ptn1.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.addPartition(ptn1);
Partition ptn2 =
new Partition(partVals2, dbName, tblName, 0, 0, sd, new HashMap<>());
ptn2.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.addPartition(ptn2);
代码示例来源:origin: apache/hive
private Partition convertToPart(MPartition mpart) throws MetaException {
if (mpart == null) {
return null;
}
//its possible that MPartition is partially filled, do null checks to avoid NPE
MTable table = mpart.getTable();
String dbName =
table == null ? null : table.getDatabase() == null ? null : table.getDatabase().getName();
String tableName = table == null ? null : table.getTableName();
String catName = table == null ? null :
table.getDatabase() == null ? null : table.getDatabase().getCatalogName();
Partition p = new Partition(convertList(mpart.getValues()), dbName, tableName, mpart.getCreateTime(),
mpart.getLastAccessTime(), convertToStorageDescriptor(mpart.getSd()),
convertMap(mpart.getParameters()));
p.setCatName(catName);
p.setWriteId(mpart.getWriteId());
return p;
}
代码示例来源:origin: apache/hive
@Test(expected = InvalidObjectException.class)
public void noSuchCatalog() throws TException {
String tableName = "table_for_no_such_catalog";
Table table = new TableBuilder()
.setTableName(tableName)
.addCol("id", "int")
.addCol("name", "string")
.addPartCol("partcol", "string")
.create(client, metaStore.getConf());
Partition part = new PartitionBuilder()
.inTable(table)
.addValue("a")
.build(metaStore.getConf());
// Explicitly mis-set the catalog name
part.setCatName("nosuch");
client.add_partition(part);
}
内容来源于网络,如有侵权,请联系作者删除!