Search in sources :

Example 36 with TableDto

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;
    });
}
Also used : PartitionsSaveRequestDto(com.netflix.metacat.common.dto.PartitionsSaveRequestDto) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) TableDto(com.netflix.metacat.common.dto.TableDto)

Example 37 with TableDto

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;
}
Also used : PartitionsSaveRequestDto(com.netflix.metacat.common.dto.PartitionsSaveRequestDto) Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) TableDto(com.netflix.metacat.common.dto.TableDto) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Aggregations

TableDto (com.netflix.metacat.common.dto.TableDto)37 QualifiedName (com.netflix.metacat.common.QualifiedName)14 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)12 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)10 Partition (org.apache.hadoop.hive.metastore.api.Partition)7 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)6 ConnectorContext (com.netflix.metacat.common.server.connectors.ConnectorContext)5 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)5 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)4 MetacatUpdateTablePostEvent (com.netflix.metacat.common.server.events.MetacatUpdateTablePostEvent)4 EventListener (org.springframework.context.event.EventListener)4 Splitter (com.google.common.base.Splitter)3 Strings (com.google.common.base.Strings)3 Lists (com.google.common.collect.Lists)3 FieldDto (com.netflix.metacat.common.dto.FieldDto)3 StorageDto (com.netflix.metacat.common.dto.StorageDto)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2