use of com.netflix.metacat.common.dto.PartitionsSaveRequestDto in project metacat by Netflix.
the class PartitionServiceImpl method update.
@Override
public void update(@Nonnull final QualifiedName name, @Nonnull final PartitionDto partitionDto) {
final PartitionsSaveRequestDto dto = new PartitionsSaveRequestDto();
dto.setPartitions(Lists.newArrayList(partitionDto));
save(name, dto);
}
use of com.netflix.metacat.common.dto.PartitionsSaveRequestDto in project metacat by Netflix.
the class PartitionServiceImpl method delete.
@Override
public void delete(final QualifiedName name, final List<String> partitionIds) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
registry.gauge(this.partitionDeletedCountId.withTags(new HashMap<>(name.parts())), partitionIds.size());
if (!tableService.exists(name)) {
throw new TableNotFoundException(name);
}
if (!partitionIds.isEmpty()) {
final PartitionsSaveRequestDto dto = new PartitionsSaveRequestDto();
dto.setPartitionIdsForDeletes(partitionIds);
eventBus.postSync(new MetacatDeleteTablePartitionPreEvent(name, metacatRequestContext, this, dto));
final ConnectorPartitionService service = connectorManager.getPartitionService(name.getCatalogName());
// Get the partitions before calling delete
final GetPartitionsRequestDto requestDto = new GetPartitionsRequestDto();
requestDto.setIncludePartitionDetails(false);
requestDto.setPartitionNames(partitionIds);
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
final List<PartitionInfo> partitionInfos = service.getPartitions(connectorContext, name, converterUtil.toPartitionListRequest(requestDto, null, null));
List<HasMetadata> partitions = Lists.newArrayList();
if (partitionInfos != null) {
partitions = partitionInfos.stream().map(converterUtil::toPartitionDto).collect(Collectors.toList());
}
log.info("Deleting partitions with names {} for {}", partitionIds, name);
service.deletePartitions(connectorContext, name, partitionIds);
// delete metadata
log.info("Deleting user metadata for partitions with names {} for {}", partitionIds, name);
if (!partitions.isEmpty()) {
deleteMetadatas(metacatRequestContext.getUserName(), partitions);
}
eventBus.postAsync(new MetacatDeleteTablePartitionPostEvent(name, metacatRequestContext, this, partitionIds));
}
}
use of com.netflix.metacat.common.dto.PartitionsSaveRequestDto in project metacat by Netflix.
the class MViewServiceImpl method deletePartitions.
@Override
public void deletePartitions(@Nonnull final QualifiedName name, final List<String> partitionIds) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final PartitionsSaveRequestDto dto = new PartitionsSaveRequestDto();
dto.setPartitionIdsForDeletes(partitionIds);
eventBus.postSync(new MetacatDeleteMViewPartitionPreEvent(name, metacatRequestContext, this, dto));
final QualifiedName viewQName = QualifiedName.ofTable(name.getCatalogName(), VIEW_DB_NAME, createViewName(name));
partitionService.delete(viewQName, partitionIds);
eventBus.postAsync(new MetacatDeleteMViewPartitionPostEvent(name, metacatRequestContext, this, partitionIds));
}
use of com.netflix.metacat.common.dto.PartitionsSaveRequestDto 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.PartitionsSaveRequestDto 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