Source:
private void assertTableStatsComputed( SchemaTableName tableName, Set<String> expectedColumnStatsColumns) { try (Transaction transaction = newTransaction()) { ConnectorMetadata metadata = transaction.getMetadata(); ConnectorSession session = newSession(); ConnectorTableHandle tableHandle = getTableHandle(metadata, tableName); TableStatistics tableStatistics = metadata.getTableStatistics(session, tableHandle, Constraint.alwaysTrue()); assertFalse(tableStatistics.getRowCount().isValueUnknown(), "row count is unknown"); Map<String, ColumnStatistics> columnsStatistics = tableStatistics .getColumnStatistics() .entrySet() .stream() .collect( toImmutableMap( entry -> ((HiveColumnHandle) entry.getKey()).getName(), Map.Entry::getValue)); assertEquals(columnsStatistics.keySet(), expectedColumnStatsColumns, "columns with statistics"); columnsStatistics.forEach((columnName, columnStatistics) -> { ColumnHandle columnHandle = metadata.getColumnHandles(session, tableHandle).get(columnName); Type columnType = metadata.getColumnMetadata(session, tableHandle, columnHandle).getType(); assertFalse( columnStatistics.getNullsFraction().isValueUnknown(), "unknown nulls fraction for " + columnName); RangeColumnStatistics rangeColumnStatistics = columnStatistics.getOnlyRangeColumnStatistics(); assertFalse( rangeColumnStatistics.getDistinctValuesCount().isValueUnknown(), "unknown range distinct values count for " + columnName); assertFalse( rangeColumnStatistics.getFraction().isValueUnknown(), "unknown range non-null fraction for " + columnName); if (isVarcharType(columnType)) { assertFalse( rangeColumnStatistics.getDataSize().isValueUnknown(), "unknown range data size for " + columnName); } else { assertTrue( rangeColumnStatistics.getDataSize().isValueUnknown(), "known range data size for" + columnName); } }); } }

Target:
private void assertTableStatsComputed( SchemaTableName tableName, Set<String> expectedColumnStatsColumns) { try (Transaction transaction = newTransaction()) { ConnectorMetadata metadata = transaction.getMetadata(); ConnectorSession session = newSession(); ConnectorTableHandle tableHandle = getTableHandle(metadata, tableName); TableStatistics tableStatistics = metadata.getTableStatistics(session, tableHandle, Constraint.alwaysTrue()); assertFalse(tableStatistics.getRowCount().isValueUnknown(), "row count is unknown"); Map<String, ColumnStatistics> columnsStatistics = tableStatistics .getColumnStatistics() .entrySet() .stream() .collect( toImmutableMap( entry -> ((HiveColumnHandle) entry.getKey()).getName(), Map.Entry::getValue)); assertEquals(columnsStatistics.keySet(), expectedColumnStatsColumns, "columns with statistics"); Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle); columnsStatistics.forEach((columnName, columnStatistics) -> { ColumnHandle columnHandle = columnHandles.get(columnName); Type columnType = metadata.getColumnMetadata(session, tableHandle, columnHandle).getType(); assertFalse( columnStatistics.getNullsFraction().isValueUnknown(), "unknown nulls fraction for " + columnName); RangeColumnStatistics rangeColumnStatistics = columnStatistics.getOnlyRangeColumnStatistics(); assertFalse( rangeColumnStatistics.getDistinctValuesCount().isValueUnknown(), "unknown range distinct values count for " + columnName); assertFalse( rangeColumnStatistics.getFraction().isValueUnknown(), "unknown range non-null fraction for " + columnName); if (isVarcharType(columnType)) { assertFalse( rangeColumnStatistics.getDataSize().isValueUnknown(), "unknown range data size for " + columnName); } else { assertTrue( rangeColumnStatistics.getDataSize().isValueUnknown(), "known range data size for" + columnName); } }); } }