Search in sources :

Example 11 with Partition

use of com.netflix.metacat.connector.s3.model.Partition in project metacat by Netflix.

the class S3ConnectorPartitionService method get.

@Override
public PartitionInfo get(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName name) {
    final QualifiedName tableName = QualifiedName.ofTable(catalogName, name.getDatabaseName(), name.getTableName());
    final Table table = getTable(tableName);
    final List<Partition> partitions = partitionDao.getPartitions(table.getId(), Lists.newArrayList(name.getPartitionName()), null, null, null, null);
    if (partitions.isEmpty()) {
        throw new PartitionNotFoundException(tableName, name.getPartitionName());
    }
    log.debug("Get partition for table {}", tableName);
    return infoConverter.toPartitionInfo(tableName, table, partitions.get(0));
}
Also used : Partition(com.netflix.metacat.connector.s3.model.Partition) FilterPartition(com.netflix.metacat.common.server.partition.util.FilterPartition) PartitionNotFoundException(com.netflix.metacat.common.server.connectors.exception.PartitionNotFoundException) Table(com.netflix.metacat.connector.s3.model.Table) QualifiedName(com.netflix.metacat.common.QualifiedName)

Example 12 with Partition

use of com.netflix.metacat.connector.s3.model.Partition in project metacat by Netflix.

the class S3ConnectorPartitionService method create.

@Override
public void create(@Nonnull final ConnectorContext context, @Nonnull final PartitionInfo partitionInfo) {
    final QualifiedName name = partitionInfo.getName();
    log.debug("Start: Create partition {}", name);
    final QualifiedName tableName = QualifiedName.ofTable(catalogName, name.getDatabaseName(), name.getTableName());
    // Table
    final Table table = getTable(tableName);
    final List<Partition> partitions = partitionDao.getPartitions(table.getId(), Lists.newArrayList(name.getPartitionName()), null, null, null, null);
    if (!partitions.isEmpty()) {
        throw new PartitionAlreadyExistsException(tableName, name.getPartitionName());
    }
    partitionDao.save(infoConverter.toPartition(table, partitionInfo));
    log.debug("End: Create partition {}", name);
}
Also used : Partition(com.netflix.metacat.connector.s3.model.Partition) FilterPartition(com.netflix.metacat.common.server.partition.util.FilterPartition) Table(com.netflix.metacat.connector.s3.model.Table) QualifiedName(com.netflix.metacat.common.QualifiedName) PartitionAlreadyExistsException(com.netflix.metacat.common.server.connectors.exception.PartitionAlreadyExistsException)

Aggregations

Partition (com.netflix.metacat.connector.s3.model.Partition)11 QualifiedName (com.netflix.metacat.common.QualifiedName)9 FilterPartition (com.netflix.metacat.common.server.partition.util.FilterPartition)9 Table (com.netflix.metacat.connector.s3.model.Table)9 PartitionNotFoundException (com.netflix.metacat.common.server.connectors.exception.PartitionNotFoundException)7 PartitionAlreadyExistsException (com.netflix.metacat.common.server.connectors.exception.PartitionAlreadyExistsException)5 Strings (com.google.common.base.Strings)3 Lists (com.google.common.collect.Lists)3 Maps (com.google.common.collect.Maps)3 Transactional (com.google.inject.persist.Transactional)3 Pageable (com.netflix.metacat.common.dto.Pageable)3 Sort (com.netflix.metacat.common.dto.Sort)3 ConnectorPartitionService (com.netflix.metacat.common.server.connectors.ConnectorPartitionService)3 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)3 BaseInfo (com.netflix.metacat.common.server.connectors.model.BaseInfo)3 PartitionInfo (com.netflix.metacat.common.server.connectors.model.PartitionInfo)3 PartitionListRequest (com.netflix.metacat.common.server.connectors.model.PartitionListRequest)3 PartitionsSaveRequest (com.netflix.metacat.common.server.connectors.model.PartitionsSaveRequest)3 PartitionsSaveResponse (com.netflix.metacat.common.server.connectors.model.PartitionsSaveResponse)3 PartitionParser (com.netflix.metacat.common.server.partition.parser.PartitionParser)3