Search in sources :

Example 1 with DateStatistics

use of io.trino.plugin.hive.metastore.DateStatistics in project trino by trinodb.

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());
}
Also used : DateStatistics(io.trino.plugin.hive.metastore.DateStatistics) Test(org.testng.annotations.Test)

Example 2 with DateStatistics

use of io.trino.plugin.hive.metastore.DateStatistics in project trino by trinodb.

the class TestThriftMetastoreUtil 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));
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) DateColumnStatsData(org.apache.hadoop.hive.metastore.api.DateColumnStatsData) DateStatistics(io.trino.plugin.hive.metastore.DateStatistics) HiveColumnStatistics(io.trino.plugin.hive.metastore.HiveColumnStatistics) LocalDate(java.time.LocalDate) Date(org.apache.hadoop.hive.metastore.api.Date) Test(org.testng.annotations.Test)

Example 3 with DateStatistics

use of io.trino.plugin.hive.metastore.DateStatistics in project trino by trinodb.

the class TestThriftMetastoreUtil 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());
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) DateColumnStatsData(org.apache.hadoop.hive.metastore.api.DateColumnStatsData) DateStatistics(io.trino.plugin.hive.metastore.DateStatistics) HiveColumnStatistics(io.trino.plugin.hive.metastore.HiveColumnStatistics) Test(org.testng.annotations.Test)

Aggregations

DateStatistics (io.trino.plugin.hive.metastore.DateStatistics)3 Test (org.testng.annotations.Test)3 HiveColumnStatistics (io.trino.plugin.hive.metastore.HiveColumnStatistics)2 ColumnStatisticsObj (org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj)2 DateColumnStatsData (org.apache.hadoop.hive.metastore.api.DateColumnStatsData)2 LocalDate (java.time.LocalDate)1 Date (org.apache.hadoop.hive.metastore.api.Date)1