use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class CatalogThriftHiveMetastore method rename_partition.
/**
* {@inheritDoc}
*/
@Override
public void rename_partition(final String dbName, final String tblName, final List<String> partVals, final Partition newPart) throws TException {
requestWrapper("rename_partition", new Object[] { dbName, tblName, partVals }, () -> {
final TableDto tableDto = getTableDto(dbName, tblName);
final String partName = hiveConverters.getNameFromPartVals(tableDto, partVals);
final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto();
final PartitionDto partitionDto = hiveConverters.hiveToMetacatPartition(tableDto, newPart);
partitionsSaveRequestDto.setPartitions(Lists.newArrayList(partitionDto));
partitionsSaveRequestDto.setPartitionIdsForDeletes(Lists.newArrayList(partName));
partV1.savePartitions(catalogName, dbName, tblName, partitionsSaveRequestDto);
return null;
});
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class CatalogThriftHiveMetastore method addPartitionsCore.
private List<Partition> addPartitionsCore(final String dbName, final String tblName, final List<Partition> parts, final boolean ifNotExists) throws TException {
log.debug("Ignoring {} since metacat save partitions will do an update if it already exists", ifNotExists);
final TableDto tableDto = v1.getTable(catalogName, dbName, tblName, true, false, false);
if (tableDto.getPartition_keys() == null || tableDto.getPartition_keys().isEmpty()) {
throw new MetaException("Unable to add partition to unpartitioned table: " + tableDto.getName());
}
final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto();
final List<PartitionDto> converted = Lists.newArrayListWithCapacity(parts.size());
for (Partition partition : parts) {
converted.add(hiveConverters.hiveToMetacatPartition(tableDto, partition));
}
partitionsSaveRequestDto.setPartitions(converted);
partV1.savePartitions(catalogName, dbName, tblName, partitionsSaveRequestDto);
return parts;
}
Aggregations