prestodb/presto · error · PrestoException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
Table-wide statistic type not supported:
What it means
StatisticsAggregationPlanner.createStatisticsAggregation builds the aggregation used to compute table-wide statistics during writes (e.g. ANALYZE or CTAS stats collection). Only ROW_COUNT table statistics are currently supported; if the table's statistics metadata requests any other TableStatisticType, NOT_SUPPORTED is thrown.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/planner/StatisticsAggregationPlanner.java:95
public TableStatisticAggregation createStatisticsAggregation(TableStatisticsMetadata statisticsMetadata, Map<String, VariableReferenceExpression> columnToVariableMap)
{
StatisticAggregationsDescriptor.Builder<VariableReferenceExpression> descriptor = StatisticAggregationsDescriptor.builder();
List<String> groupingColumns = statisticsMetadata.getGroupingColumns();
List<VariableReferenceExpression> groupingVariables = groupingColumns.stream()
.map(columnToVariableMap::get)
.collect(toImmutableList());
for (int i = 0; i < groupingVariables.size(); i++) {
descriptor.addGrouping(groupingColumns.get(i), groupingVariables.get(i));
}
ImmutableMap.Builder<VariableReferenceExpression, RowExpression> additionalVariables = ImmutableMap.builder();
ImmutableMap.Builder<VariableReferenceExpression, AggregationNode.Aggregation> aggregations = ImmutableMap.builder();
StandardFunctionResolution functionResolution = new FunctionResolution(functionAndTypeResolver);
for (TableStatisticType type : statisticsMetadata.getTableStatistics()) {
if (type != ROW_COUNT) {
throw new PrestoException(NOT_SUPPORTED, "Table-wide statistic type not supported: " + type);
}
AggregationNode.Aggregation aggregation = new AggregationNode.Aggregation(
new CallExpression(
"count",
functionResolution.countFunction(),
BIGINT,
ImmutableList.of()),
Optional.empty(),
Optional.empty(),
false,
Optional.empty());
VariableReferenceExpression variable = variableAllocator.newVariable("rowCount", BIGINT);
aggregations.put(variable, aggregation);
descriptor.addTableStatistic(ROW_COUNT, variable);
}
for (ColumnStatisticMetadata columnStatisticMetadata : statisticsMetadata.getColumnStatistics()) {
if (!useHistograms && columnStatisticMetadata.getStatisticType() == ColumnStatisticType.HISTOGRAM) {View on GitHub (pinned to 55bb57d202)
Solutions
- Restrict the connector's TableStatisticType support to ROW_COUNT if you own the connector
- Disable table statistics collection for the affected tables/catalog
- Upgrade the Presto engine to a version supporting the declared statistic types
- Check statisticsMetadata.getTableStatistics() source in the connector and align declared types with engine capabilities
Example fix
// before (connector metadata) getTableStatistics() -> [ROW_COUNT, MAX_VALUE_SIZE] // after getTableStatistics() -> [ROW_COUNT]
Defensive patterns
Strategy: validation
Validate before calling
// Check declared table statistic types before writes that collect stats
List<TableStatisticType> types = getTableStatisticsMetadata(table).getTableStatistics();
if (!new HashSet<>(types).equals(Set.of(TableStatisticType.ROW_COUNT))) {
throw new IllegalStateException("Only ROW_COUNT table statistics are supported: " + types);
} Type guard
boolean supportsStatistics(TableStatisticType type) {
return type == TableStatisticType.ROW_COUNT;
} Try / catch
try {
executeCtasOrAnalyze(sql);
} catch (PrestoException e) {
if ("NOT_SUPPORTED".equals(e.getErrorCode().getName()) && e.getMessage().startsWith("Table-wide statistic type not supported")) {
throw new IllegalStateException("Disable extended table statistics or upgrade engine", e);
}
throw e;
} Prevention
- Only enable statistics collection for connectors advertising ROW_COUNT
- Keep connector-declared statistic types within engine support
- Test stats-enabled writes after connector upgrades
- Check table statistics metadata before ANALYZE/CTAS
When it happens
Trigger: Writing to a table (CREATE TABLE AS, INSERT, or ANALYZE) whose connector declares table statistics types other than ROW_COUNT in its statistics metadata, so the loop encounters type != ROW_COUNT.
Common situations: Using a connector that advertises extended table statistics (e.g. min/max or NDV) that the Presto engine version doesn't implement; enabling statistics collection on tables after a connector upgrade changed declared stats types.
Understand the failure class
Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/5e87c1d5aa0b67d4.
Report an issue: GitHub.