use of com.facebook.presto.hive.metastore.DateStatistics in project presto by prestodb.
the class TestStatistics method testMergeDateColumnStatistics.
@Test
public void testMergeDateColumnStatistics() {
assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.empty(), Optional.empty())).build(), HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.empty(), Optional.empty())).build(), HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.empty(), Optional.empty())).build());
assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.of(LocalDate.ofEpochDay(1)), Optional.of(LocalDate.ofEpochDay(2)))).build(), HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.empty(), Optional.empty())).build(), HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.of(LocalDate.ofEpochDay(1)), Optional.of(LocalDate.ofEpochDay(2)))).build());
assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.of(LocalDate.ofEpochDay(1)), Optional.of(LocalDate.ofEpochDay(2)))).build(), HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.of(LocalDate.ofEpochDay(0)), Optional.of(LocalDate.ofEpochDay(3)))).build(), HiveColumnStatistics.builder().setDateStatistics(new DateStatistics(Optional.of(LocalDate.ofEpochDay(0)), Optional.of(LocalDate.ofEpochDay(3)))).build());
}
use of com.facebook.presto.hive.metastore.DateStatistics in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testDateStatsToColumnStatistics.
@Test
public void testDateStatsToColumnStatistics() {
DateColumnStatsData dateColumnStatsData = new DateColumnStatsData();
dateColumnStatsData.setLowValue(new Date(1000));
dateColumnStatsData.setHighValue(new Date(2000));
dateColumnStatsData.setNumNulls(1);
dateColumnStatsData.setNumDVs(20);
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DATE_TYPE_NAME, dateStats(dateColumnStatsData));
HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));
assertEquals(actual.getIntegerStatistics(), Optional.empty());
assertEquals(actual.getDoubleStatistics(), Optional.empty());
assertEquals(actual.getDecimalStatistics(), Optional.empty());
assertEquals(actual.getDateStatistics(), Optional.of(new DateStatistics(Optional.of(LocalDate.ofEpochDay(1000)), Optional.of(LocalDate.ofEpochDay(2000)))));
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 com.facebook.presto.hive.metastore.DateStatistics in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testEmptyDateStatsToColumnStatistics.
@Test
public void testEmptyDateStatsToColumnStatistics() {
DateColumnStatsData emptyDateColumnStatsData = new DateColumnStatsData();
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DATE_TYPE_NAME, dateStats(emptyDateColumnStatsData));
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.of(new DateStatistics(Optional.empty(), Optional.empty())));
assertEquals(actual.getBooleanStatistics(), Optional.empty());
assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getTotalSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getNullsCount(), OptionalLong.empty());
assertEquals(actual.getDistinctValuesCount(), OptionalLong.empty());
}
use of com.facebook.presto.hive.metastore.DateStatistics in project presto by prestodb.
the class HiveSplitManager method getDateColumnStatisticsValueSet.
private Optional<ValueSet> getDateColumnStatisticsValueSet(HiveColumnStatistics statistics, Type type) {
if (!statistics.getDateStatistics().isPresent()) {
return Optional.empty();
}
DateStatistics hiveColumnStatistics = statistics.getDateStatistics().get();
ValueSet result = ValueSet.all(type);
if (hiveColumnStatistics.getMin().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.greaterThanOrEqual(type, hiveColumnStatistics.getMin().get().toEpochDay()))));
}
if (hiveColumnStatistics.getMax().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.lessThanOrEqual(type, hiveColumnStatistics.getMax().get().toEpochDay()))));
}
return Optional.of(result);
}
Aggregations