Search in sources :

Example 6 with HiveColumnStatistics

use of com.facebook.presto.hive.metastore.HiveColumnStatistics in project presto by prestodb.

the class TestThriftHiveMetastoreUtil method testLongStatsToColumnStatistics.

@Test
public void testLongStatsToColumnStatistics() {
    LongColumnStatsData longColumnStatsData = new LongColumnStatsData();
    longColumnStatsData.setLowValue(0);
    longColumnStatsData.setHighValue(100);
    longColumnStatsData.setNumNulls(1);
    longColumnStatsData.setNumDVs(20);
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", BIGINT_TYPE_NAME, longStats(longColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));
    assertEquals(actual.getIntegerStatistics(), Optional.of(new IntegerStatistics(OptionalLong.of(0), OptionalLong.of(100))));
    assertEquals(actual.getDoubleStatistics(), Optional.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.of(1));
    assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(19));
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) LongColumnStatsData(org.apache.hadoop.hive.metastore.api.LongColumnStatsData) IntegerStatistics(com.facebook.presto.hive.metastore.IntegerStatistics) Test(org.testng.annotations.Test)

Example 7 with HiveColumnStatistics

use of com.facebook.presto.hive.metastore.HiveColumnStatistics in project presto by prestodb.

the class TestThriftHiveMetastoreUtil method testEmptyLongStatsToColumnStatistics.

@Test
public void testEmptyLongStatsToColumnStatistics() {
    LongColumnStatsData emptyLongColumnStatsData = new LongColumnStatsData();
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", BIGINT_TYPE_NAME, longStats(emptyLongColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.empty());
    assertEquals(actual.getIntegerStatistics(), Optional.of(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty())));
    assertEquals(actual.getDoubleStatistics(), Optional.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 : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) LongColumnStatsData(org.apache.hadoop.hive.metastore.api.LongColumnStatsData) IntegerStatistics(com.facebook.presto.hive.metastore.IntegerStatistics) Test(org.testng.annotations.Test)

Example 8 with HiveColumnStatistics

use of com.facebook.presto.hive.metastore.HiveColumnStatistics in project presto by prestodb.

the class TestThriftHiveMetastoreUtil method testStringStatsToColumnStatistics.

@Test
public void testStringStatsToColumnStatistics() {
    StringColumnStatsData stringColumnStatsData = new StringColumnStatsData();
    stringColumnStatsData.setMaxColLen(100);
    stringColumnStatsData.setAvgColLen(23.333);
    stringColumnStatsData.setNumNulls(1);
    stringColumnStatsData.setNumDVs(20);
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", STRING_TYPE_NAME, stringStats(stringColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(2));
    assertEquals(actual.getIntegerStatistics(), Optional.empty());
    assertEquals(actual.getDoubleStatistics(), Optional.empty());
    assertEquals(actual.getDecimalStatistics(), Optional.empty());
    assertEquals(actual.getDateStatistics(), Optional.empty());
    assertEquals(actual.getBooleanStatistics(), Optional.empty());
    assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.of(100));
    assertEquals(actual.getTotalSizeInBytes(), OptionalLong.of(23));
    assertEquals(actual.getNullsCount(), OptionalLong.of(1));
    assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(1));
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) StringColumnStatsData(org.apache.hadoop.hive.metastore.api.StringColumnStatsData) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) Test(org.testng.annotations.Test)

Example 9 with HiveColumnStatistics

use of com.facebook.presto.hive.metastore.HiveColumnStatistics in project presto by prestodb.

the class TestThriftHiveMetastoreUtil 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(com.facebook.presto.hive.metastore.DoubleStatistics) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) Test(org.testng.annotations.Test)

Example 10 with HiveColumnStatistics

use of com.facebook.presto.hive.metastore.HiveColumnStatistics 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());
}
Also used : BooleanColumnStatsData(org.apache.hadoop.hive.metastore.api.BooleanColumnStatsData) ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) BooleanStatistics(com.facebook.presto.hive.metastore.BooleanStatistics) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) Test(org.testng.annotations.Test)

Aggregations

HiveColumnStatistics (com.facebook.presto.hive.metastore.HiveColumnStatistics)23 ColumnStatisticsObj (org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj)16 Test (org.testng.annotations.Test)15 PartitionStatistics (com.facebook.presto.hive.metastore.PartitionStatistics)8 HiveBasicStatistics (com.facebook.presto.hive.HiveBasicStatistics)6 SchemaTableName (com.facebook.presto.spi.SchemaTableName)6 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)5 PrestoException (com.facebook.presto.spi.PrestoException)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 Map (java.util.Map)5 Optional (java.util.Optional)5 Type (com.facebook.presto.common.type.Type)4 DateStatistics (com.facebook.presto.hive.metastore.DateStatistics)4 DoubleStatistics (com.facebook.presto.hive.metastore.DoubleStatistics)4 Chars.isCharType (com.facebook.presto.common.type.Chars.isCharType)3 DATE (com.facebook.presto.common.type.DateType.DATE)3 Varchars.isVarcharType (com.facebook.presto.common.type.Varchars.isVarcharType)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 String.format (java.lang.String.format)3