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"); 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); assertFalse( columnStatistics.getDistinctValuesCount().isValueUnknown(), "unknown range distinct values count for " + columnName); if (isVarcharType(columnType)) { assertFalse( columnStatistics.getDataSize().isValueUnknown(), "unknown range data size for " + columnName); } else { assertTrue( columnStatistics.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().isUnknown(), "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().isUnknown(), "unknown nulls fraction for " + columnName); assertFalse( columnStatistics.getDistinctValuesCount().isUnknown(), "unknown distinct values count for " + columnName); if (isVarcharType(columnType)) { assertFalse( columnStatistics.getDataSize().isUnknown(), "unknown data size for " + columnName); } else { assertTrue( columnStatistics.getDataSize().isUnknown(), "unknown data size for" + columnName); } }); } }