@VisibleForTesting
    static Estimate calculateDataSizeForPartitioningKey(
            HiveColumnHandle column,
            Type type,
            List<HivePartition> partitions,
            Map<String, PartitionStatistics> statistics,
            double averageRowsPerPartition)
    {
        if (!hasDataSize(type)) {
            return Estimate.unknown();
        }
        double dataSize = 0;
        for (HivePartition partition : partitions) {
            int length = getSize(partition.getKeys().get(column));
            double rowCount = getPartitionRowCount(partition.getPartitionId().getPartitionName(), statistics).orElse(averageRowsPerPartition);
            dataSize += length * rowCount;
        }
        return Estimate.of(dataSize);
    }
@Test
    public void testCalculateDataSizeForPartitioningKey()
    {
        assertEquals(
                calculateDataSizeForPartitioningKey(
                        PARTITION_COLUMN_2,
                        BIGINT,
                        ImmutableList.of(partition("p1=string1/p2=1234")),
                        ImmutableMap.of("p1=string1/p2=1234", rowsCount(1000)),
                        2000),
                Estimate.unknown());
        assertEquals(
                calculateDataSizeForPartitioningKey(
                        PARTITION_COLUMN_1,
                        VARCHAR,
                        ImmutableList.of(partition("p1=string1/p2=1234")),
                        ImmutableMap.of("p1=string1/p2=1234", rowsCount(1000)),
                        2000),
                Estimate.of(7000));
        assertEquals(
                calculateDataSizeForPartitioningKey(
                        PARTITION_COLUMN_1,
                        VARCHAR,
                        ImmutableList.of(partition("p1=string1/p2=1234")),
                        ImmutableMap.of("p1=string1/p2=1234", PartitionStatistics.empty()),
                        2000),
                Estimate.of(14000));
        assertEquals(
                calculateDataSizeForPartitioningKey(
                        PARTITION_COLUMN_1,
                        VARCHAR,
                        ImmutableList.of(partition("p1=string1/p2=1234"), partition("p1=str2/p2=1234")),
                        ImmutableMap.of("p1=string1/p2=1234", rowsCount(1000), "p1=str2/p2=1234", rowsCount(2000)),
                        3000),
                Estimate.of(15000));
        assertEquals(
                calculateDataSizeForPartitioningKey(
                        PARTITION_COLUMN_1,
                        VARCHAR,
                        ImmutableList.of(partition("p1=string1/p2=1234"), partition("p1=str2/p2=1234")),
                        ImmutableMap.of("p1=string1/p2=1234", rowsCount(1000), "p1=str2/p2=1234", PartitionStatistics.empty()),
                        3000),
                Estimate.of(19000));
        assertEquals(
                calculateDataSizeForPartitioningKey(
                        PARTITION_COLUMN_1,
                        VARCHAR,
                        ImmutableList.of(partition("p1=string1/p2=1234"), partition("p1=str2/p2=1234")),
                        ImmutableMap.of(),
                        3000),
                Estimate.of(33000));
        assertEquals(
                calculateDataSizeForPartitioningKey(
                        PARTITION_COLUMN_1,
                        VARCHAR,
                        ImmutableList.of(partition("p1=__HIVE_DEFAULT_PARTITION__/p2=1234"), partition("p1=str2/p2=1234")),
                        ImmutableMap.of(),
                        3000),
                Estimate.of(12000));
    }