class 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));
    }

    public  MetastoreHiveStatisticsProvider(SemiTransactionalHiveMetastore metastore);
    @VisibleForTesting  MetastoreHiveStatisticsProvider(PartitionsStatisticsProvider statisticsProvider);

}