### Question:
MetastoreHiveStatisticsProvider implements HiveStatisticsProvider { @VisibleForTesting static long calculateDistinctPartitionKeys( HiveColumnHandle column, List<HivePartition> partitions) { return partitions.stream() .map(partition -> partition.getKeys().get(column)) .filter(value -> !value.isNull()) .distinct() .count(); } 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 testCalculateDistinctPartitionKeys() { assertEquals(calculateDistinctPartitionKeys(PARTITION_COLUMN_1, ImmutableList.of()), 0); assertEquals( calculateDistinctPartitionKeys( PARTITION_COLUMN_1, ImmutableList.of(partition("p1=string1/p2=1234"))), 1); assertEquals( calculateDistinctPartitionKeys( PARTITION_COLUMN_1, ImmutableList.of(partition("p1=string1/p2=1234"), partition("p1=string2/p2=1234"))), 2); assertEquals( calculateDistinctPartitionKeys( PARTITION_COLUMN_2, ImmutableList.of(partition("p1=string1/p2=1234"), partition("p1=string2/p2=1234"))), 1); assertEquals( calculateDistinctPartitionKeys( PARTITION_COLUMN_2, ImmutableList.of(partition("p1=string1/p2=1234"), partition("p1=string1/p2=1235"))), 2); assertEquals( calculateDistinctPartitionKeys( PARTITION_COLUMN_1, ImmutableList.of(partition("p1=__HIVE_DEFAULT_PARTITION__/p2=1234"), partition("p1=string1/p2=1235"))), 1); assertEquals( calculateDistinctPartitionKeys( PARTITION_COLUMN_2, ImmutableList.of(partition("p1=123/p2=__HIVE_DEFAULT_PARTITION__"), partition("p1=string1/p2=1235"))), 1); assertEquals( calculateDistinctPartitionKeys( PARTITION_COLUMN_2, ImmutableList.of(partition("p1=123/p2=__HIVE_DEFAULT_PARTITION__"), partition("p1=string1/p2=__HIVE_DEFAULT_PARTITION__"))), 0); }