Search in sources :

Example 1 with ColumnStats

use of org.apache.flink.table.plan.stats.ColumnStats in project flink by apache.

the class CatalogTableStatisticsConverter method convertToColumnStatsMap.

@VisibleForTesting
public static Map<String, ColumnStats> convertToColumnStatsMap(Map<String, CatalogColumnStatisticsDataBase> columnStatisticsData) {
    Map<String, ColumnStats> columnStatsMap = new HashMap<>();
    for (Map.Entry<String, CatalogColumnStatisticsDataBase> entry : columnStatisticsData.entrySet()) {
        if (entry.getValue() != null) {
            ColumnStats columnStats = convertToColumnStats(entry.getValue());
            columnStatsMap.put(entry.getKey(), columnStats);
        }
    }
    return columnStatsMap;
}
Also used : HashMap(java.util.HashMap) CatalogColumnStatisticsDataBase(org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase) ColumnStats(org.apache.flink.table.plan.stats.ColumnStats) CatalogColumnStatisticsDataString(org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataString) HashMap(java.util.HashMap) Map(java.util.Map) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting)

Example 2 with ColumnStats

use of org.apache.flink.table.plan.stats.ColumnStats in project flink by apache.

the class CatalogTableStatisticsConverterTest method testConvertToColumnStatsMapWithNullColumnStatisticsData.

@Test
public void testConvertToColumnStatsMapWithNullColumnStatisticsData() {
    Map<String, CatalogColumnStatisticsDataBase> columnStatisticsDataBaseMap = new HashMap<>();
    columnStatisticsDataBaseMap.put("first", new CatalogColumnStatisticsDataString(10L, 5.2, 3L, 100L));
    columnStatisticsDataBaseMap.put("second", null);
    Map<String, ColumnStats> columnStatsMap = CatalogTableStatisticsConverter.convertToColumnStatsMap(columnStatisticsDataBaseMap);
    assertNotNull(columnStatsMap);
    assertEquals(columnStatisticsDataBaseMap.size() - 1, columnStatsMap.size());
    assertTrue(columnStatsMap.containsKey("first"));
    assertFalse(columnStatsMap.containsKey("second"));
}
Also used : CatalogColumnStatisticsDataBase(org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase) HashMap(java.util.HashMap) ColumnStats(org.apache.flink.table.plan.stats.ColumnStats) CatalogColumnStatisticsDataString(org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataString) CatalogColumnStatisticsDataString(org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataString) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 CatalogColumnStatisticsDataBase (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase)2 CatalogColumnStatisticsDataString (org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataString)2 ColumnStats (org.apache.flink.table.plan.stats.ColumnStats)2 Map (java.util.Map)1 VisibleForTesting (org.apache.flink.annotation.VisibleForTesting)1 Test (org.junit.Test)1