Source:
public synchronized Map<String, PartitionStatistics> getPartitionStatistics(String databaseName, String tableName, Set<String> partitionNames) { checkReadable(); Optional<Table> table = getTable(databaseName, tableName); if (!table.isPresent()) { return ImmutableMap.of(); } TableSource tableSource = getTableSource(databaseName, tableName); Map<List<String>, Action<PartitionAndMore>> partitionActionsOfTable = partitionActions.computeIfAbsent(new SchemaTableName(databaseName, tableName), k -> new HashMap<>()); ImmutableSet.Builder<String> partitionNamesToQuery = ImmutableSet.builder(); ImmutableMap.Builder<String, PartitionStatistics> resultBuilder = ImmutableMap.builder(); for (String partitionName : partitionNames) { List<String> partitionValues = toPartitionValues(partitionName); Action<PartitionAndMore> partitionAction = partitionActionsOfTable.get(partitionValues); if (partitionAction == null) { switch (tableSource) { case PRE_EXISTING_TABLE: partitionNamesToQuery.add(partitionName); break; case CREATED_IN_THIS_TRANSACTION: resultBuilder.put(partitionName, new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of())); break; default: throw new UnsupportedOperationException("unknown table source"); } } else { resultBuilder.put(partitionName, new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of())); } } Map<String, PartitionStatistics> delegateResult = delegate.getPartitionStatistics(databaseName, tableName, partitionNamesToQuery.build()); if (!delegateResult.isEmpty()) { resultBuilder.putAll(delegateResult); } else { partitionNamesToQuery.build().forEach(partitionName -> resultBuilder.put(partitionName, new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of()))); } return resultBuilder.build(); }

Target:
public synchronized Map<String, PartitionStatistics> getPartitionStatistics(String databaseName, String tableName, Set<String> partitionNames) { checkReadable(); Optional<Table> table = getTable(databaseName, tableName); if (!table.isPresent()) { return ImmutableMap.of(); } TableSource tableSource = getTableSource(databaseName, tableName); Map<List<String>, Action<PartitionAndMore>> partitionActionsOfTable = partitionActions.computeIfAbsent(new SchemaTableName(databaseName, tableName), k -> new HashMap<>()); ImmutableSet.Builder<String> partitionNamesToQuery = ImmutableSet.builder(); ImmutableMap.Builder<String, PartitionStatistics> resultBuilder = ImmutableMap.builder(); for (String partitionName : partitionNames) { List<String> partitionValues = toPartitionValues(partitionName); Action<PartitionAndMore> partitionAction = partitionActionsOfTable.get(partitionValues); if (partitionAction == null) { switch (tableSource) { case PRE_EXISTING_TABLE: partitionNamesToQuery.add(partitionName); break; case CREATED_IN_THIS_TRANSACTION: resultBuilder.put(partitionName, PartitionStatistics.empty()); break; default: throw new UnsupportedOperationException("unknown table source"); } } else { resultBuilder.put(partitionName, partitionAction.getData().getStatistics()); } } Map<String, PartitionStatistics> delegateResult = delegate.getPartitionStatistics(databaseName, tableName, partitionNamesToQuery.build()); if (!delegateResult.isEmpty()) { resultBuilder.putAll(delegateResult); } else { partitionNamesToQuery.build().forEach(partitionName -> resultBuilder.put(partitionName, PartitionStatistics.empty())); } return resultBuilder.build(); }