use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testEmptyBooleanStatsToColumnStatistics.
@Test
public void testEmptyBooleanStatsToColumnStatistics() {
BooleanColumnStatsData emptyBooleanColumnStatsData = new BooleanColumnStatsData();
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", BOOLEAN_TYPE_NAME, booleanStats(emptyBooleanColumnStatsData));
HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.empty());
assertEquals(actual.getIntegerStatistics(), Optional.empty());
assertEquals(actual.getDoubleStatistics(), Optional.empty());
assertEquals(actual.getDecimalStatistics(), Optional.empty());
assertEquals(actual.getDateStatistics(), Optional.empty());
assertEquals(actual.getBooleanStatistics(), Optional.of(new BooleanStatistics(OptionalLong.empty(), OptionalLong.empty())));
assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getTotalSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getNullsCount(), OptionalLong.empty());
assertEquals(actual.getDistinctValuesCount(), OptionalLong.empty());
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testDecimalStatsToColumnStatistics.
@Test
public void testDecimalStatsToColumnStatistics() {
DecimalColumnStatsData decimalColumnStatsData = new DecimalColumnStatsData();
BigDecimal low = new BigDecimal("0");
decimalColumnStatsData.setLowValue(toMetastoreDecimal(low));
BigDecimal high = new BigDecimal("100");
decimalColumnStatsData.setHighValue(toMetastoreDecimal(high));
decimalColumnStatsData.setNumNulls(1);
decimalColumnStatsData.setNumDVs(20);
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DECIMAL_TYPE_NAME, decimalStats(decimalColumnStatsData));
HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));
assertEquals(actual.getIntegerStatistics(), Optional.empty());
assertEquals(actual.getDoubleStatistics(), Optional.empty());
assertEquals(actual.getDecimalStatistics(), Optional.of(new DecimalStatistics(Optional.of(low), Optional.of(high))));
assertEquals(actual.getDateStatistics(), Optional.empty());
assertEquals(actual.getBooleanStatistics(), Optional.empty());
assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getTotalSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getNullsCount(), OptionalLong.of(1));
assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(19));
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testSingleDistinctValue.
@Test
public void testSingleDistinctValue() {
DoubleColumnStatsData doubleColumnStatsData = new DoubleColumnStatsData();
doubleColumnStatsData.setNumNulls(10);
doubleColumnStatsData.setNumDVs(1);
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DOUBLE_TYPE_NAME, doubleStats(doubleColumnStatsData));
HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(10));
assertEquals(actual.getNullsCount(), OptionalLong.of(10));
assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(0));
doubleColumnStatsData = new DoubleColumnStatsData();
doubleColumnStatsData.setNumNulls(10);
doubleColumnStatsData.setNumDVs(1);
columnStatisticsObj = new ColumnStatisticsObj("my_col", DOUBLE_TYPE_NAME, doubleStats(doubleColumnStatsData));
actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(11));
assertEquals(actual.getNullsCount(), OptionalLong.of(10));
assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(1));
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testBooleanStatsToColumnStatistics.
@Test
public void testBooleanStatsToColumnStatistics() {
BooleanColumnStatsData booleanColumnStatsData = new BooleanColumnStatsData();
booleanColumnStatsData.setNumTrues(100);
booleanColumnStatsData.setNumFalses(10);
booleanColumnStatsData.setNumNulls(0);
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", BOOLEAN_TYPE_NAME, booleanStats(booleanColumnStatsData));
HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.empty());
assertEquals(actual.getIntegerStatistics(), Optional.empty());
assertEquals(actual.getDoubleStatistics(), Optional.empty());
assertEquals(actual.getDecimalStatistics(), Optional.empty());
assertEquals(actual.getDateStatistics(), Optional.empty());
assertEquals(actual.getBooleanStatistics(), Optional.of(new BooleanStatistics(OptionalLong.of(100), OptionalLong.of(10))));
assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getTotalSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getNullsCount(), OptionalLong.of(0));
assertEquals(actual.getDistinctValuesCount(), OptionalLong.empty());
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj in project flink by apache.
the class HiveStatsUtil method createCatalogColumnStats.
/**
* Create a map of Flink column stats from the given Hive column stats.
*/
public static Map<String, CatalogColumnStatisticsDataBase> createCatalogColumnStats(@Nonnull List<ColumnStatisticsObj> hiveColStats, String hiveVersion) {
checkNotNull(hiveColStats, "hiveColStats can not be null");
Map<String, CatalogColumnStatisticsDataBase> colStats = new HashMap<>();
for (ColumnStatisticsObj colStatsObj : hiveColStats) {
CatalogColumnStatisticsDataBase columnStats = createTableColumnStats(HiveTypeUtil.toFlinkType(TypeInfoUtils.getTypeInfoFromTypeString(colStatsObj.getColType())), colStatsObj.getStatsData(), hiveVersion);
colStats.put(colStatsObj.getColName(), columnStats);
}
return colStats;
}
Aggregations