Search in sources :

Example 11 with CatalogColumnStatistics

use of org.apache.flink.table.catalog.stats.CatalogColumnStatistics in project flink by apache.

the class GenericInMemoryCatalog method getPartitionColumnStatistics.

@Override
public CatalogColumnStatistics getPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec) throws PartitionNotExistException {
    checkNotNull(tablePath);
    checkNotNull(partitionSpec);
    if (!partitionExists(tablePath, partitionSpec)) {
        throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
    }
    CatalogColumnStatistics result = partitionColumnStats.get(tablePath).get(partitionSpec);
    return result != null ? result.copy() : CatalogColumnStatistics.UNKNOWN;
}
Also used : PartitionNotExistException(org.apache.flink.table.catalog.exceptions.PartitionNotExistException) CatalogColumnStatistics(org.apache.flink.table.catalog.stats.CatalogColumnStatistics)

Example 12 with CatalogColumnStatistics

use of org.apache.flink.table.catalog.stats.CatalogColumnStatistics in project flink by apache.

the class DatabaseCalciteSchema method extractTableStats.

private TableStats extractTableStats(ContextResolvedTable lookupResult, ObjectIdentifier identifier) {
    if (lookupResult.isTemporary()) {
        return TableStats.UNKNOWN;
    }
    final Catalog catalog = lookupResult.getCatalog().orElseThrow(IllegalStateException::new);
    final ObjectPath tablePath = identifier.toObjectPath();
    try {
        final CatalogTableStatistics tableStatistics = catalog.getTableStatistics(tablePath);
        final CatalogColumnStatistics columnStatistics = catalog.getTableColumnStatistics(tablePath);
        return convertToTableStats(tableStatistics, columnStatistics);
    } catch (TableNotExistException e) {
        throw new ValidationException(format("Could not get statistic for table: [%s, %s, %s]", identifier.getCatalogName(), tablePath.getDatabaseName(), tablePath.getObjectName()), e);
    }
}
Also used : ObjectPath(org.apache.flink.table.catalog.ObjectPath) ValidationException(org.apache.flink.table.api.ValidationException) TableNotExistException(org.apache.flink.table.catalog.exceptions.TableNotExistException) Catalog(org.apache.flink.table.catalog.Catalog) CatalogColumnStatistics(org.apache.flink.table.catalog.stats.CatalogColumnStatistics) CatalogTableStatistics(org.apache.flink.table.catalog.stats.CatalogTableStatistics)

Aggregations

CatalogColumnStatistics (org.apache.flink.table.catalog.stats.CatalogColumnStatistics)12 HashMap (java.util.HashMap)6 CatalogColumnStatisticsDataBase (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase)6 CatalogColumnStatisticsDataString (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataString)6 CatalogColumnStatisticsDataLong (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataLong)5 CatalogColumnStatisticsDataDate (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataDate)4 CatalogColumnStatisticsDataDouble (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataDouble)4 CatalogTableStatistics (org.apache.flink.table.catalog.stats.CatalogTableStatistics)4 CatalogPartitionSpec (org.apache.flink.table.catalog.CatalogPartitionSpec)3 CatalogTable (org.apache.flink.table.catalog.CatalogTable)3 PartitionNotExistException (org.apache.flink.table.catalog.exceptions.PartitionNotExistException)3 TableNotExistException (org.apache.flink.table.catalog.exceptions.TableNotExistException)3 CatalogColumnStatisticsDataBoolean (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBoolean)3 Date (org.apache.flink.table.catalog.stats.Date)3 Test (org.junit.Test)3 LinkedHashMap (java.util.LinkedHashMap)2 ObjectPath (org.apache.flink.table.catalog.ObjectPath)2 CatalogColumnStatisticsDataBinary (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBinary)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1