### Question:
MetastoreHiveStatisticsProvider implements HiveStatisticsProvider { @VisibleForTesting static Estimate calculateNullsFraction(String column, Collection<PartitionStatistics> partitionStatistics) { List<PartitionStatistics> statisticsWithKnownRowCountAndNullsCount = partitionStatistics.stream() .filter(statistics -> { if (statistics.getBasicStatistics().getRowCount().isEmpty()) { return false; } HiveColumnStatistics columnStatistics = statistics.getColumnStatistics().get(column); if (columnStatistics == null) { return false; } return columnStatistics.getNullsCount().isPresent(); }) .collect(toImmutableList()); if (statisticsWithKnownRowCountAndNullsCount.isEmpty()) { return Estimate.unknown(); } long totalNullsCount = 0; long totalRowCount = 0; for (PartitionStatistics statistics : statisticsWithKnownRowCountAndNullsCount) { long rowCount = statistics.getBasicStatistics().getRowCount().orElseThrow(() -> new VerifyException("rowCount is not present")); verify(rowCount >= 0, "rowCount must be greater than or equal to zero"); HiveColumnStatistics columnStatistics = statistics.getColumnStatistics().get(column); verifyNotNull(columnStatistics, "columnStatistics is null"); long nullsCount = columnStatistics.getNullsCount().orElseThrow(() -> new VerifyException("nullsCount is not present")); verify(nullsCount >= 0, "nullsCount must be greater than or equal to zero"); verify(nullsCount <= rowCount, "nullsCount must be less than or equal to rowCount. nullsCount: %s. rowCount: %s.", nullsCount, rowCount); totalNullsCount += nullsCount; totalRowCount += rowCount; } if (totalRowCount == 0) { return Estimate.zero(); } verify( totalNullsCount <= totalRowCount, "totalNullsCount must be less than or equal to totalRowCount. totalNullsCount: %s. totalRowCount: %s.", totalNullsCount, totalRowCount); return Estimate.of(((double) totalNullsCount) / totalRowCount); } 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 testCalculateNullsFraction() { assertEquals(calculateNullsFraction(COLUMN, ImmutableList.of()), Estimate.unknown()); assertEquals(calculateNullsFraction(COLUMN, ImmutableList.of(PartitionStatistics.empty())), Estimate.unknown()); assertEquals(calculateNullsFraction(COLUMN, ImmutableList.of(rowsCount(1000))), Estimate.unknown()); assertEquals(calculateNullsFraction(COLUMN, ImmutableList.of(rowsCount(1000), nullsCount(500))), Estimate.unknown()); assertEquals(calculateNullsFraction(COLUMN, ImmutableList.of(rowsCount(1000), nullsCount(500), rowsCountAndNullsCount(1000, 500))), Estimate.of(0.5)); assertEquals(calculateNullsFraction(COLUMN, ImmutableList.of(rowsCountAndNullsCount(2000, 200), rowsCountAndNullsCount(1000, 100))), Estimate.of(0.1)); assertEquals(calculateNullsFraction(COLUMN, ImmutableList.of(rowsCountAndNullsCount(0, 0), rowsCountAndNullsCount(0, 0))), Estimate.of(0)); }