Search in sources :

Example 1 with DoubleStatistics

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

the class TestStatistics method testCreateDoubleHiveColumnStatistics.

@Test
public void testCreateDoubleHiveColumnStatistics() {
    HiveColumnStatistics statistics;
    statistics = createDoubleColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(DOUBLE, -2391d), MAX_VALUE, nativeValueToBlock(DOUBLE, 42d)));
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.of(-2391d), OptionalDouble.of(42)));
    statistics = createDoubleColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(DOUBLE, Double.NEGATIVE_INFINITY), MAX_VALUE, nativeValueToBlock(DOUBLE, Double.POSITIVE_INFINITY)));
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty()));
    statistics = createDoubleColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(DOUBLE, Double.NaN), MAX_VALUE, nativeValueToBlock(DOUBLE, Double.NaN)));
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty()));
    statistics = createDoubleColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(DOUBLE, -15d), MAX_VALUE, nativeValueToBlock(DOUBLE, -0d)));
    // TODO should we distinguish between -0 and 0?
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.of(-15d), OptionalDouble.of(-0d)));
}
Also used : DoubleStatistics(io.trino.plugin.hive.metastore.DoubleStatistics) HiveColumnStatistics(io.trino.plugin.hive.metastore.HiveColumnStatistics) Statistics.createHiveColumnStatistics(io.trino.plugin.hive.util.Statistics.createHiveColumnStatistics) Test(org.testng.annotations.Test)

Example 2 with DoubleStatistics

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

the class TestThriftMetastoreUtil method testEmptyDoubleStatsToColumnStatistics.

@Test
public void testEmptyDoubleStatsToColumnStatistics() {
    DoubleColumnStatsData emptyDoubleColumnStatsData = new DoubleColumnStatsData();
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DOUBLE_TYPE_NAME, doubleStats(emptyDoubleColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.empty());
    assertEquals(actual.getIntegerStatistics(), Optional.empty());
    assertEquals(actual.getDoubleStatistics(), Optional.of(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())));
    assertEquals(actual.getDecimalStatistics(), Optional.empty());
    assertEquals(actual.getDateStatistics(), 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 : DoubleColumnStatsData(org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData) ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) DoubleStatistics(io.trino.plugin.hive.metastore.DoubleStatistics) HiveColumnStatistics(io.trino.plugin.hive.metastore.HiveColumnStatistics) Test(org.testng.annotations.Test)

Example 3 with DoubleStatistics

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

the class TestStatistics method testCreateRealHiveColumnStatistics.

@Test
public void testCreateRealHiveColumnStatistics() {
    HiveColumnStatistics statistics;
    statistics = createRealColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(-2391f)), MAX_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(42f))));
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.of(-2391d), OptionalDouble.of(42)));
    statistics = createRealColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(Float.NEGATIVE_INFINITY)), MAX_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(Float.POSITIVE_INFINITY))));
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty()));
    statistics = createRealColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(Float.NaN)), MAX_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(Float.NaN))));
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty()));
    statistics = createRealColumnStatistics(ImmutableMap.of(MIN_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(-15f)), MAX_VALUE, nativeValueToBlock(REAL, (long) floatToIntBits(-0f))));
    // TODO should we distinguish between -0 and 0?
    assertThat(statistics.getDoubleStatistics().get()).isEqualTo(new DoubleStatistics(OptionalDouble.of(-15d), OptionalDouble.of(-0d)));
}
Also used : DoubleStatistics(io.trino.plugin.hive.metastore.DoubleStatistics) HiveColumnStatistics(io.trino.plugin.hive.metastore.HiveColumnStatistics) Statistics.createHiveColumnStatistics(io.trino.plugin.hive.util.Statistics.createHiveColumnStatistics) Test(org.testng.annotations.Test)

Example 4 with DoubleStatistics

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

the class TestStatistics method testMergeDoubleColumnStatistics.

@Test
public void testMergeDoubleColumnStatistics() {
    assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build());
    assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(1), OptionalDouble.of(2))).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(1), OptionalDouble.of(2))).build());
    assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(1), OptionalDouble.of(2))).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(0), OptionalDouble.of(3))).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(0), OptionalDouble.of(3))).build());
}
Also used : DoubleStatistics(io.trino.plugin.hive.metastore.DoubleStatistics) Test(org.testng.annotations.Test)

Example 5 with DoubleStatistics

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

the class TestThriftMetastoreUtil method testDoubleStatsToColumnStatistics.

@Test
public void testDoubleStatsToColumnStatistics() {
    DoubleColumnStatsData doubleColumnStatsData = new DoubleColumnStatsData();
    doubleColumnStatsData.setLowValue(0);
    doubleColumnStatsData.setHighValue(100);
    doubleColumnStatsData.setNumNulls(1);
    doubleColumnStatsData.setNumDVs(20);
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DOUBLE_TYPE_NAME, doubleStats(doubleColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));
    assertEquals(actual.getIntegerStatistics(), Optional.empty());
    assertEquals(actual.getDoubleStatistics(), Optional.of(new DoubleStatistics(OptionalDouble.of(0), OptionalDouble.of(100))));
    assertEquals(actual.getDecimalStatistics(), Optional.empty());
    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));
}
Also used : DoubleColumnStatsData(org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData) ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) DoubleStatistics(io.trino.plugin.hive.metastore.DoubleStatistics) HiveColumnStatistics(io.trino.plugin.hive.metastore.HiveColumnStatistics) Test(org.testng.annotations.Test)

Aggregations

DoubleStatistics (io.trino.plugin.hive.metastore.DoubleStatistics)5 Test (org.testng.annotations.Test)5 HiveColumnStatistics (io.trino.plugin.hive.metastore.HiveColumnStatistics)4 Statistics.createHiveColumnStatistics (io.trino.plugin.hive.util.Statistics.createHiveColumnStatistics)2 ColumnStatisticsObj (org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj)2 DoubleColumnStatsData (org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData)2