### Question:
MetastoreHiveStatisticsProvider implements HiveStatisticsProvider { @VisibleForTesting static Optional<DoubleRange> calculateRangeForPartitioningKey(HiveColumnHandle column, Type type, List<HivePartition> partitions) { List<OptionalDouble> convertedValues = partitions.stream() .map(HivePartition::getKeys) .map(keys -> keys.get(column)) .filter(value -> !value.isNull()) .map(NullableValue::getValue) .map(value -> convertPartitionValueToDouble(type, value)) .collect(toImmutableList()); if (convertedValues.stream().noneMatch(OptionalDouble::isPresent)) { return Optional.empty(); } List<Double> values = convertedValues.stream() .peek(convertedValue -> checkState(convertedValue.isPresent(), "convertedValue is missing")) .map(OptionalDouble::getAsDouble) .collect(toImmutableList()); verify(!values.isEmpty()); double min = values.get(0); double max = values.get(0); for (Double value : values) { if (value > max) { max = value; } if (value < min) { min = value; } } return Optional.of(new DoubleRange(min, max)); } MetastoreHiveStatisticsProvider(SemiTransactionalHiveMetastore metastore); @VisibleForTesting  MetastoreHiveStatisticsProvider(PartitionsStatisticsProvider statisticsProvider); @Override TableStatistics getTableStatistics(
            ConnectorSession session,
            SchemaTableName table,
            Map<String, ColumnHandle> columns,
            Map<String, Type> columnTypes,
            List<HivePartition> partitions); static OptionalDouble convertPartitionValueToDouble(Type type, Object value);  }### Answer:
@Test public void testCalculateRangeForPartitioningKey() { assertEquals( calculateRangeForPartitioningKey( PARTITION_COLUMN_1, VARCHAR, ImmutableList.of(partition("p1=string1/p2=1234"))), Optional.empty()); assertEquals( calculateRangeForPartitioningKey( PARTITION_COLUMN_2, BIGINT, ImmutableList.of(partition("p1=string1/p2=__HIVE_DEFAULT_PARTITION__"))), Optional.empty()); assertEquals( calculateRangeForPartitioningKey( PARTITION_COLUMN_2, BIGINT, ImmutableList.of(partition("p1=string1/p2=__HIVE_DEFAULT_PARTITION__"), partition("p1=string1/p2=__HIVE_DEFAULT_PARTITION__"))), Optional.empty()); assertEquals( calculateRangeForPartitioningKey( PARTITION_COLUMN_2, BIGINT, ImmutableList.of(partition("p1=string1/p2=__HIVE_DEFAULT_PARTITION__"), partition("p1=string1/p2=1"))), Optional.of(new DoubleRange(1, 1))); assertEquals( calculateRangeForPartitioningKey( PARTITION_COLUMN_2, BIGINT, ImmutableList.of(partition("p1=string1/p2=2"), partition("p1=string1/p2=1"))), Optional.of(new DoubleRange(1, 2))); }