Search in sources :

Example 16 with HiveColumnStatistics

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

Example 17 with HiveColumnStatistics

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

Example 18 with HiveColumnStatistics

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

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

Example 19 with HiveColumnStatistics

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

the class TestThriftHiveMetastoreUtil method testEmptyStringColumnStatsData.

@Test
public void testEmptyStringColumnStatsData() {
    StringColumnStatsData emptyStringColumnStatsData = new StringColumnStatsData();
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", STRING_TYPE_NAME, stringStats(emptyStringColumnStatsData));
    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.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) StringColumnStatsData(org.apache.hadoop.hive.metastore.api.StringColumnStatsData) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) Test(org.testng.annotations.Test)

Example 20 with HiveColumnStatistics

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

the class TestThriftHiveMetastoreUtil method testBinaryStatsToColumnStatistics.

@Test
public void testBinaryStatsToColumnStatistics() {
    BinaryColumnStatsData binaryColumnStatsData = new BinaryColumnStatsData();
    binaryColumnStatsData.setMaxColLen(100);
    binaryColumnStatsData.setAvgColLen(22.2);
    binaryColumnStatsData.setNumNulls(2);
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", BINARY_TYPE_NAME, binaryStats(binaryColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(4));
    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(44));
    assertEquals(actual.getNullsCount(), OptionalLong.of(2));
    assertEquals(actual.getDistinctValuesCount(), OptionalLong.empty());
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) BinaryColumnStatsData(org.apache.hadoop.hive.metastore.api.BinaryColumnStatsData) 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