Source:
<code>public void testPartitionStatisticsSampling() throws Exception { SchemaTableName tableName = temporaryTable("test_partition_statistics_sampling"); try { createDummyPartitionedTable(tableName, STATISTICS_PARTITIONED_TABLE_COLUMNS); metastoreClient.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), "ds=2016-01-01", actualStatistics -> STATISTICS_1); metastoreClient.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), "ds=2016-01-02", actualStatistics -> STATISTICS_1); try (Transaction transaction = newTransaction()) { ConnectorSession session = newSession(); ConnectorMetadata metadata = transaction.getMetadata(); ConnectorTableHandle tableHandle = metadata.getTableHandle(session, tableName); Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle); TableStatistics expectedStatistics = metadata.getTableStatistics(sampleSize(2), tableHandle, Constraint.alwaysTrue()); TableStatistics sampledStatistics = metadata.getTableStatistics(sampleSize(1), tableHandle, Constraint.alwaysTrue()); assertEquals(sampledStatistics.getRowCount(), expectedStatistics.getRowCount()); for (ColumnHandle handle : columnHandles.values()) { HiveColumnHandle hiveColumnHandle = (HiveColumnHandle) handle; if (hiveColumnHandle.isHidden()) { continue; } ColumnStatistics sampled = expectedStatistics.getColumnStatistics().get(handle); ColumnStatistics expected = expectedStatistics.getColumnStatistics().get(handle); assertEquals(sampled.getNullsFraction(), expected.getNullsFraction()); assertEquals(sampled.getOnlyRangeColumnStatistics().getDistinctValuesCount(), expected.getOnlyRangeColumnStatistics().getDistinctValuesCount()); assertEquals(sampled.getOnlyRangeColumnStatistics().getLowValue(), expected.getOnlyRangeColumnStatistics().getLowValue()); assertEquals(sampled.getOnlyRangeColumnStatistics().getHighValue(), expected.getOnlyRangeColumnStatistics().getHighValue()); assertEquals(sampled.getOnlyRangeColumnStatistics().getDataSize(), expected.getOnlyRangeColumnStatistics().getDataSize()); <START> assertEquals(sampled.getOnlyRangeColumnStatistics().getFraction(), expected.getOnlyRangeColumnStatistics().getFraction()); <END> } } } finally { dropTable(tableName); } }</code><technical_language>nice replace assertions with: assertEquals(sampled, expected)</technical_language>

Target:
public void testPartitionStatisticsSampling() throws Exception { SchemaTableName tableName = temporaryTable("test_partition_statistics_sampling"); try { createDummyPartitionedTable(tableName, STATISTICS_PARTITIONED_TABLE_COLUMNS); metastoreClient.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), "ds=2016-01-01", actualStatistics -> STATISTICS_1); metastoreClient.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), "ds=2016-01-02", actualStatistics -> STATISTICS_1); try (Transaction transaction = newTransaction()) { ConnectorSession session = newSession(); ConnectorMetadata metadata = transaction.getMetadata(); ConnectorTableHandle tableHandle = metadata.getTableHandle(session, tableName); TableStatistics unsampledStatistics = metadata.getTableStatistics(sampleSize(2), tableHandle, Constraint.alwaysTrue()); TableStatistics sampledStatistics = metadata.getTableStatistics(sampleSize(1), tableHandle, Constraint.alwaysTrue()); assertEquals(sampledStatistics, unsampledStatistics); } } finally { dropTable(tableName); } }