@VisibleForTesting
    static Optional<DoubleRange> calculateRangeForPartitioningKey(HiveColumnHandle column, Type type, List<HivePartition> partitions)
    {
        if (!isRangeSupported(type)) {
            return Optional.empty();
        }

        List<Double> values = 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 (values.isEmpty()) {
            return Optional.empty();
        }

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