Search in sources :

Example 11 with TableDto

use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.

the class CatalogThriftHiveMetastore method get_partitions_by_names.

/**
 * {@inheritDoc}
 */
@Override
public List<Partition> get_partitions_by_names(final String dbName, final String tblName, final List<String> names) throws TException {
    return requestWrapper("get_partitions_by_names", new Object[] { dbName, tblName, names }, () -> {
        final String databaseName = normalizeIdentifier(dbName);
        final String tableName = normalizeIdentifier(tblName);
        final TableDto tableDto = v1.getTable(catalogName, databaseName, tableName, true, false, false);
        final GetPartitionsRequestDto dto = new GetPartitionsRequestDto(null, names, true, false);
        final List<PartitionDto> metacatPartitions = partV1.getPartitionsForRequest(catalogName, databaseName, tableName, null, null, null, null, false, dto);
        final List<Partition> result = Lists.newArrayListWithCapacity(metacatPartitions.size());
        for (PartitionDto partition : metacatPartitions) {
            result.add(hiveConverters.metacatToHivePartition(partition, tableDto));
        }
        return result;
    });
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) GetPartitionsRequestDto(com.netflix.metacat.common.dto.GetPartitionsRequestDto) TableDto(com.netflix.metacat.common.dto.TableDto)

Example 12 with TableDto

use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.

the class CatalogThriftHiveMetastore method partition_values_to_partition_filter.

/**
 * Converts the partial specification given by the part_vals to a Metacat filter statement.
 *
 * @param dbName   the name of the database
 * @param tblName  the name of the table
 * @param partVals the partial specification values
 * @return A Meta
 * cat filter expression suitable for selecting out the partitions matching the specification
 * @throws MetaException if there are more part_vals specified than partition columns on the table.
 */
@SuppressWarnings("checkstyle:methodname")
String partition_values_to_partition_filter(final String dbName, final String tblName, final List<String> partVals) throws MetaException {
    final String databaseName = normalizeIdentifier(dbName);
    final String tableName = normalizeIdentifier(tblName);
    final TableDto tableDto = v1.getTable(catalogName, databaseName, tableName, true, false, false);
    return partition_values_to_partition_filter(tableDto, partVals);
}
Also used : TableDto(com.netflix.metacat.common.dto.TableDto)

Example 13 with TableDto

use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.

the class CatalogThriftHiveMetastore method get_partitions_ps.

/**
 * {@inheritDoc}
 */
@Override
public List<Partition> get_partitions_ps(final String dbName, final String tblName, final List<String> partVals, final short maxParts) throws TException {
    return requestWrapper("get_partitions_ps", new Object[] { dbName, tblName, partVals, maxParts }, () -> {
        final String databaseName = normalizeIdentifier(dbName);
        final String tableName = normalizeIdentifier(tblName);
        final TableDto tableDto = v1.getTable(catalogName, databaseName, tableName, true, false, false);
        final String partFilter = partition_values_to_partition_filter(tableDto, partVals);
        final Integer maxValues = maxParts > 0 ? Short.toUnsignedInt(maxParts) : null;
        final List<PartitionDto> metacatPartitions = partV1.getPartitions(catalogName, dbName, tblName, partFilter, null, null, null, maxValues, false);
        final List<Partition> result = Lists.newArrayListWithCapacity(metacatPartitions.size());
        for (PartitionDto partition : metacatPartitions) {
            result.add(hiveConverters.metacatToHivePartition(partition, tableDto));
        }
        return result;
    });
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) TableDto(com.netflix.metacat.common.dto.TableDto)

Example 14 with TableDto

use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.

the class CatalogThriftHiveMetastore method get_partition.

/**
 * {@inheritDoc}
 */
@Override
public Partition get_partition(final String dbName, final String tblName, final List<String> partVals) throws TException {
    return requestWrapper("get_partition", new Object[] { dbName, tblName, partVals }, () -> {
        final TableDto tableDto = getTableDto(dbName, tblName);
        final String partName = hiveConverters.getNameFromPartVals(tableDto, partVals);
        return hiveConverters.metacatToHivePartition(getPartitionDtoByName(tableDto, partName), tableDto);
    });
}
Also used : TableDto(com.netflix.metacat.common.dto.TableDto)

Example 15 with TableDto

use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.

the class CatalogThriftHiveMetastore method get_partitions.

/**
 * {@inheritDoc}
 */
@Override
public List<Partition> get_partitions(final String dbName, final String tblName, final short maxParts) throws TException {
    return requestWrapper("get_partitions", new Object[] { dbName, tblName, maxParts }, () -> {
        final String databaseName = normalizeIdentifier(dbName);
        final String tableName = normalizeIdentifier(tblName);
        final TableDto tableDto = v1.getTable(catalogName, databaseName, tableName, true, false, false);
        final Integer maxValues = maxParts > 0 ? Short.toUnsignedInt(maxParts) : null;
        final List<PartitionDto> metacatPartitions = partV1.getPartitions(catalogName, dbName, tblName, null, null, null, null, maxValues, false);
        final List<Partition> result = Lists.newArrayListWithCapacity(metacatPartitions.size());
        for (PartitionDto partition : metacatPartitions) {
            result.add(hiveConverters.metacatToHivePartition(partition, tableDto));
        }
        return result;
    });
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) TableDto(com.netflix.metacat.common.dto.TableDto)

Aggregations

TableDto (com.netflix.metacat.common.dto.TableDto)50 QualifiedName (com.netflix.metacat.common.QualifiedName)19 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)17 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)13 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)9 EventListener (org.springframework.context.event.EventListener)9 MetacatUpdateTablePostEvent (com.netflix.metacat.common.server.events.MetacatUpdateTablePostEvent)7 Partition (org.apache.hadoop.hive.metastore.api.Partition)7 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)6 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ConnectorRequestContext (com.netflix.metacat.common.server.connectors.ConnectorRequestContext)5 MetacatDeleteTablePostEvent (com.netflix.metacat.common.server.events.MetacatDeleteTablePostEvent)5 Splitter (com.google.common.base.Splitter)4 Strings (com.google.common.base.Strings)4 Lists (com.google.common.collect.Lists)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 FieldDto (com.netflix.metacat.common.dto.FieldDto)3 PartitionsSaveRequestDto (com.netflix.metacat.common.dto.PartitionsSaveRequestDto)3