use of org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase in project flink by apache.
the class CatalogStatisticsTest method createColumnStats.
private CatalogColumnStatistics createColumnStats() {
CatalogColumnStatisticsDataBoolean booleanColStats = new CatalogColumnStatisticsDataBoolean(55L, 45L, 5L);
CatalogColumnStatisticsDataLong longColStats = new CatalogColumnStatisticsDataLong(-123L, 763322L, 23L, 77L);
CatalogColumnStatisticsDataString stringColStats = new CatalogColumnStatisticsDataString(152L, 43.5D, 20L, 0L);
CatalogColumnStatisticsDataDate dateColStats = new CatalogColumnStatisticsDataDate(new Date(71L), new Date(17923L), 100L, 0L);
CatalogColumnStatisticsDataDouble doubleColStats = new CatalogColumnStatisticsDataDouble(-123.35D, 7633.22D, 73L, 27L);
Map<String, CatalogColumnStatisticsDataBase> colStatsMap = new HashMap<>(6);
colStatsMap.put("b1", booleanColStats);
colStatsMap.put("l2", longColStats);
colStatsMap.put("s3", stringColStats);
colStatsMap.put("d4", dateColStats);
colStatsMap.put("dd5", doubleColStats);
return new CatalogColumnStatistics(colStatsMap);
}
use of org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase in project flink by apache.
the class HiveStatsUtil method createHiveColumnStatistics.
private static ColumnStatistics createHiveColumnStatistics(Map<String, CatalogColumnStatisticsDataBase> colStats, StorageDescriptor sd, ColumnStatisticsDesc desc, String hiveVersion) {
List<ColumnStatisticsObj> colStatsList = new ArrayList<>();
for (FieldSchema field : sd.getCols()) {
String hiveColName = field.getName();
String hiveColType = field.getType();
CatalogColumnStatisticsDataBase flinkColStat = colStats.get(field.getName());
if (null != flinkColStat) {
ColumnStatisticsData statsData = getColumnStatisticsData(HiveTypeUtil.toFlinkType(TypeInfoUtils.getTypeInfoFromTypeString(hiveColType)), flinkColStat, hiveVersion);
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj(hiveColName, hiveColType, statsData);
colStatsList.add(columnStatisticsObj);
}
}
return new ColumnStatistics(desc, colStatsList);
}
use of org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase in project flink by apache.
the class GenericInMemoryCatalogTest method createColumnStats.
private CatalogColumnStatistics createColumnStats() {
CatalogColumnStatisticsDataBoolean booleanColStats = new CatalogColumnStatisticsDataBoolean(55L, 45L, 5L);
CatalogColumnStatisticsDataLong longColStats = new CatalogColumnStatisticsDataLong(-123L, 763322L, 23L, 79L);
CatalogColumnStatisticsDataString stringColStats = new CatalogColumnStatisticsDataString(152L, 43.5D, 20L, 0L);
CatalogColumnStatisticsDataDate dateColStats = new CatalogColumnStatisticsDataDate(new Date(71L), new Date(17923L), 1321L, 0L);
CatalogColumnStatisticsDataDouble doubleColStats = new CatalogColumnStatisticsDataDouble(-123.35D, 7633.22D, 23L, 79L);
CatalogColumnStatisticsDataBinary binaryColStats = new CatalogColumnStatisticsDataBinary(755L, 43.5D, 20L);
Map<String, CatalogColumnStatisticsDataBase> colStatsMap = new HashMap<>(6);
colStatsMap.put("b1", booleanColStats);
colStatsMap.put("l2", longColStats);
colStatsMap.put("s3", stringColStats);
colStatsMap.put("d4", dateColStats);
colStatsMap.put("dd5", doubleColStats);
colStatsMap.put("bb6", binaryColStats);
return new CatalogColumnStatistics(colStatsMap);
}
use of org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase 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;
}
use of org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase 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"));
}
Aggregations