Search in sources :

Example 16 with HiveBasicStatistics

use of com.facebook.presto.hive.HiveBasicStatistics in project presto by prestodb.

the class AlluxioHiveMetastore method getTableStatistics.

@Override
public PartitionStatistics getTableStatistics(MetastoreContext metastoreContext, String databaseName, String tableName) {
    try {
        Table table = getTable(metastoreContext, databaseName, tableName).orElseThrow(() -> new PrestoException(HIVE_METASTORE_ERROR, String.format("Could not retrieve table %s.%s", databaseName, tableName)));
        HiveBasicStatistics basicStatistics = getHiveBasicStatistics(table.getParameters());
        List<Column> columns = table.getPartitionColumns();
        List<String> columnNames = columns.stream().map(Column::getName).collect(toImmutableList());
        List<ColumnStatisticsInfo> columnStatistics = client.getTableColumnStatistics(table.getDatabaseName(), table.getTableName(), columnNames);
        return new PartitionStatistics(basicStatistics, groupStatisticsByColumn(metastoreContext, columnStatistics, basicStatistics.getRowCount()));
    } catch (Exception e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}
Also used : Table(com.facebook.presto.hive.metastore.Table) Column(com.facebook.presto.hive.metastore.Column) PartitionStatistics(com.facebook.presto.hive.metastore.PartitionStatistics) ColumnStatisticsInfo(alluxio.grpc.table.ColumnStatisticsInfo) PrestoException(com.facebook.presto.spi.PrestoException) MetastoreUtil.getHiveBasicStatistics(com.facebook.presto.hive.metastore.MetastoreUtil.getHiveBasicStatistics) HiveBasicStatistics(com.facebook.presto.hive.HiveBasicStatistics) NotFoundException(com.facebook.presto.spi.NotFoundException) PrestoException(com.facebook.presto.spi.PrestoException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) TableNotFoundException(com.facebook.presto.spi.TableNotFoundException)

Example 17 with HiveBasicStatistics

use of com.facebook.presto.hive.HiveBasicStatistics in project presto by prestodb.

the class FileHiveMetastore method getTableStatistics.

@Override
public synchronized PartitionStatistics getTableStatistics(MetastoreContext metastoreContext, String databaseName, String tableName) {
    Path tableMetadataDirectory = getTableMetadataDirectory(databaseName, tableName);
    TableMetadata tableMetadata = readSchemaFile("table", tableMetadataDirectory, tableCodec).orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName)));
    HiveBasicStatistics basicStatistics = getHiveBasicStatistics(tableMetadata.getParameters());
    Map<String, HiveColumnStatistics> columnStatistics = tableMetadata.getColumnStatistics();
    return new PartitionStatistics(basicStatistics, columnStatistics);
}
Also used : Path(org.apache.hadoop.fs.Path) TableNotFoundException(com.facebook.presto.spi.TableNotFoundException) PartitionStatistics(com.facebook.presto.hive.metastore.PartitionStatistics) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) MetastoreUtil.getHiveBasicStatistics(com.facebook.presto.hive.metastore.MetastoreUtil.getHiveBasicStatistics) HiveBasicStatistics(com.facebook.presto.hive.HiveBasicStatistics) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Aggregations

HiveBasicStatistics (com.facebook.presto.hive.HiveBasicStatistics)17 PartitionStatistics (com.facebook.presto.hive.metastore.PartitionStatistics)11 MetastoreUtil.getHiveBasicStatistics (com.facebook.presto.hive.metastore.MetastoreUtil.getHiveBasicStatistics)9 SchemaTableName (com.facebook.presto.spi.SchemaTableName)7 TableNotFoundException (com.facebook.presto.spi.TableNotFoundException)7 HiveColumnStatistics (com.facebook.presto.hive.metastore.HiveColumnStatistics)6 PrestoException (com.facebook.presto.spi.PrestoException)6 Column (com.facebook.presto.hive.metastore.Column)5 Domain (com.facebook.presto.common.predicate.Domain)4 Type (com.facebook.presto.common.type.Type)4 HIVE_METASTORE_ERROR (com.facebook.presto.hive.HiveErrorCode.HIVE_METASTORE_ERROR)4 HiveType (com.facebook.presto.hive.HiveType)4 PartitionNotFoundException (com.facebook.presto.hive.PartitionNotFoundException)4 HivePrivilegeInfo (com.facebook.presto.hive.metastore.HivePrivilegeInfo)4 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)4 MetastoreUtil.convertPredicateToParts (com.facebook.presto.hive.metastore.MetastoreUtil.convertPredicateToParts)4 PartitionWithStatistics (com.facebook.presto.hive.metastore.PartitionWithStatistics)4 ThriftMetastoreUtil.fromMetastoreApiTable (com.facebook.presto.hive.metastore.thrift.ThriftMetastoreUtil.fromMetastoreApiTable)4 OptionalLong (java.util.OptionalLong)4 Test (org.testng.annotations.Test)4