Search in sources :

Example 1 with ThriftMetastoreUtil.getHiveBasicStatistics

use of io.trino.plugin.hive.metastore.thrift.ThriftMetastoreUtil.getHiveBasicStatistics in project trino by trinodb.

the class AlluxioHiveMetastore method getTableStatistics.

@Override
public PartitionStatistics getTableStatistics(Table table) {
    try {
        HiveBasicStatistics basicStats = ThriftMetastoreUtil.getHiveBasicStatistics(table.getParameters());
        List<Column> columns = new ArrayList<>(table.getPartitionColumns());
        columns.addAll(table.getDataColumns());
        List<String> columnNames = columns.stream().map(Column::getName).collect(Collectors.toList());
        List<ColumnStatisticsInfo> colStatsList = client.getTableColumnStatistics(table.getDatabaseName(), table.getTableName(), columnNames);
        return new PartitionStatistics(basicStats, groupStatisticsByColumn(colStatsList, basicStats.getRowCount()));
    } catch (Exception e) {
        throw new TrinoException(HIVE_METASTORE_ERROR, e);
    }
}
Also used : Column(io.trino.plugin.hive.metastore.Column) PartitionStatistics(io.trino.plugin.hive.PartitionStatistics) ArrayList(java.util.ArrayList) ColumnStatisticsInfo(alluxio.grpc.table.ColumnStatisticsInfo) TrinoException(io.trino.spi.TrinoException) ThriftMetastoreUtil.getHiveBasicStatistics(io.trino.plugin.hive.metastore.thrift.ThriftMetastoreUtil.getHiveBasicStatistics) HiveBasicStatistics(io.trino.plugin.hive.HiveBasicStatistics) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) TrinoException(io.trino.spi.TrinoException) NotFoundException(alluxio.exception.status.NotFoundException)

Aggregations

AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)1 NotFoundException (alluxio.exception.status.NotFoundException)1 ColumnStatisticsInfo (alluxio.grpc.table.ColumnStatisticsInfo)1 HiveBasicStatistics (io.trino.plugin.hive.HiveBasicStatistics)1 PartitionStatistics (io.trino.plugin.hive.PartitionStatistics)1 Column (io.trino.plugin.hive.metastore.Column)1 ThriftMetastoreUtil.getHiveBasicStatistics (io.trino.plugin.hive.metastore.thrift.ThriftMetastoreUtil.getHiveBasicStatistics)1 TrinoException (io.trino.spi.TrinoException)1 ArrayList (java.util.ArrayList)1