Source:
public TableStatistics getTableStatistics(ConnectorSession session, ConnectorTableHandle tableHandle, List<HivePartition> hivePartitions, Map<String, ColumnHandle> tableColumns) { if (!isStatisticsEnabled(session)) { return TableStatistics.EMPTY_STATISTICS; } Map<String, PartitionStatistics> partitionStatistics = getPartitionsStatistics((HiveTableHandle) tableHandle, hivePartitions, tableColumns.keySet()); TableStatistics.Builder tableStatistics = TableStatistics.builder(); Estimate rowCount = calculateRowsCount(partitionStatistics); tableStatistics.setRowCount(rowCount); for (Map.Entry<String, ColumnHandle> columnEntry : tableColumns.entrySet()) { String columnName = columnEntry.getKey(); HiveColumnHandle hiveColumnHandle = (HiveColumnHandle) columnEntry.getValue(); if (getColumnMetadata(hiveColumnHandle).isHidden()) { continue; } ColumnStatistics.Builder columnStatistics = ColumnStatistics.builder(); RangeColumnStatistics.Builder rangeStatistics = RangeColumnStatistics.builder(); Estimate nullsFraction; if (hiveColumnHandle.isPartitionKey()) { rangeStatistics.setDistinctValuesCount(countDistinctPartitionKeys(hiveColumnHandle, hivePartitions)); nullsFraction = calculateNullsFractionForPartitioningKey(hiveColumnHandle, hivePartitions, partitionStatistics); } else { rangeStatistics.setDistinctValuesCount(calculateDistinctValuesCount(partitionStatistics, columnName)); nullsFraction = calculateNullsFraction(partitionStatistics, columnName, rowCount); } columnStatistics.setNullsFraction(nullsFraction); rangeStatistics.setFraction(nullsFraction.map(value -> 1.0 - value)); columnStatistics.addRange(rangeStatistics.build()); tableStatistics.setColumnStatistics(hiveColumnHandle, columnStatistics.build()); } return tableStatistics.build(); }

Target:
public TableStatistics getTableStatistics(ConnectorSession session, ConnectorTableHandle tableHandle, List<HivePartition> hivePartitions, Map<String, ColumnHandle> tableColumns) { if (!isStatisticsEnabled(session)) { return TableStatistics.EMPTY_STATISTICS; } Map<String, PartitionStatistics> partitionStatistics = getPartitionsStatistics((HiveTableHandle) tableHandle, hivePartitions, tableColumns.keySet()); TableStatistics.Builder tableStatistics = TableStatistics.builder(); Estimate rowCount = calculateRowsCount(partitionStatistics); tableStatistics.setRowCount(rowCount); for (Map.Entry<String, ColumnHandle> columnEntry : tableColumns.entrySet()) { String columnName = columnEntry.getKey(); HiveColumnHandle hiveColumnHandle = (HiveColumnHandle) columnEntry.getValue(); if (getColumnMetadata(hiveColumnHandle).isHidden()) { continue; } RangeColumnStatistics.Builder rangeStatistics = RangeColumnStatistics.builder(); Estimate nullsFraction; if (hiveColumnHandle.isPartitionKey()) { rangeStatistics.setDistinctValuesCount(countDistinctPartitionKeys(hiveColumnHandle, hivePartitions)); nullsFraction = calculateNullsFractionForPartitioningKey(hiveColumnHandle, hivePartitions, partitionStatistics); } else { rangeStatistics.setDistinctValuesCount(calculateDistinctValuesCount(partitionStatistics, columnName)); nullsFraction = calculateNullsFraction(partitionStatistics, columnName, rowCount); } rangeStatistics.setFraction(nullsFraction.map(value -> 1.0 - value)); ColumnStatistics.Builder columnStatistics = ColumnStatistics.builder(); columnStatistics.setNullsFraction(nullsFraction); columnStatistics.addRange(rangeStatistics.build()); tableStatistics.setColumnStatistics(hiveColumnHandle, columnStatistics.build()); } return tableStatistics.build(); }