Java Code Examples for org.apache.hadoop.hive.metastore.api.DecimalColumnStatsData#setNumDVs()

The following examples show how to use org.apache.hadoop.hive.metastore.api.DecimalColumnStatsData#setNumDVs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestObjects.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 6 votes vote down vote up
public static org.apache.hadoop.hive.metastore.api.ColumnStatisticsData getHiveDecimalColumnStatsData() {
  DecimalColumnStatsData statsData = new DecimalColumnStatsData();
  org.apache.hadoop.hive.metastore.api.Decimal highValue = new org.apache.hadoop.hive.metastore.api.Decimal();
  highValue.setScale((short) 1);
  highValue.setUnscaled(BigInteger.valueOf(1234L).toByteArray());
  statsData.setHighValue(highValue);
  org.apache.hadoop.hive.metastore.api.Decimal lowValue = new org.apache.hadoop.hive.metastore.api.Decimal();
  lowValue.setScale((short) 4);
  lowValue.setUnscaled(BigInteger.valueOf(5678L).toByteArray());
  statsData.setLowValue(lowValue);
  statsData.setNumDVs(12L);
  statsData.setNumNulls(56L);
  org.apache.hadoop.hive.metastore.api.ColumnStatisticsData  statsWrapper =
          new org.apache.hadoop.hive.metastore.api.ColumnStatisticsData();
  statsWrapper.setDecimalStats(statsData);
  return statsWrapper;
}
 
Example 2
Source File: TestThriftMetastoreUtil.java    From presto with Apache License 2.0 6 votes vote down vote up
@Test
public void testDecimalStatsToColumnStatistics()
{
    DecimalColumnStatsData decimalColumnStatsData = new DecimalColumnStatsData();
    BigDecimal low = new BigDecimal("0");
    decimalColumnStatsData.setLowValue(toMetastoreDecimal(low));
    BigDecimal high = new BigDecimal("100");
    decimalColumnStatsData.setHighValue(toMetastoreDecimal(high));
    decimalColumnStatsData.setNumNulls(1);
    decimalColumnStatsData.setNumDVs(20);
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DECIMAL_TYPE_NAME, decimalStats(decimalColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));

    assertEquals(actual.getIntegerStatistics(), Optional.empty());
    assertEquals(actual.getDoubleStatistics(), Optional.empty());
    assertEquals(actual.getDecimalStatistics(), Optional.of(new DecimalStatistics(Optional.of(low), Optional.of(high))));
    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));
}