{"record":{"id":"5e87c1d5aa0b67d4","repo":"prestodb/presto","slug":"not-supported-5e87c1","errorCode":"NOT_SUPPORTED","errorMessage":"Table-wide statistic type not supported: ","messagePattern":"Table-wide statistic type not supported: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/StatisticsAggregationPlanner.java","lineNumber":95,"sourceCode":"    public TableStatisticAggregation createStatisticsAggregation(TableStatisticsMetadata statisticsMetadata, Map<String, VariableReferenceExpression> columnToVariableMap)\n    {\n        StatisticAggregationsDescriptor.Builder<VariableReferenceExpression> descriptor = StatisticAggregationsDescriptor.builder();\n\n        List<String> groupingColumns = statisticsMetadata.getGroupingColumns();\n        List<VariableReferenceExpression> groupingVariables = groupingColumns.stream()\n                .map(columnToVariableMap::get)\n                .collect(toImmutableList());\n\n        for (int i = 0; i < groupingVariables.size(); i++) {\n            descriptor.addGrouping(groupingColumns.get(i), groupingVariables.get(i));\n        }\n        ImmutableMap.Builder<VariableReferenceExpression, RowExpression> additionalVariables = ImmutableMap.builder();\n\n        ImmutableMap.Builder<VariableReferenceExpression, AggregationNode.Aggregation> aggregations = ImmutableMap.builder();\n        StandardFunctionResolution functionResolution = new FunctionResolution(functionAndTypeResolver);\n        for (TableStatisticType type : statisticsMetadata.getTableStatistics()) {\n            if (type != ROW_COUNT) {\n                throw new PrestoException(NOT_SUPPORTED, \"Table-wide statistic type not supported: \" + type);\n            }\n            AggregationNode.Aggregation aggregation = new AggregationNode.Aggregation(\n                    new CallExpression(\n                            \"count\",\n                            functionResolution.countFunction(),\n                            BIGINT,\n                            ImmutableList.of()),\n                    Optional.empty(),\n                    Optional.empty(),\n                    false,\n                    Optional.empty());\n            VariableReferenceExpression variable = variableAllocator.newVariable(\"rowCount\", BIGINT);\n            aggregations.put(variable, aggregation);\n            descriptor.addTableStatistic(ROW_COUNT, variable);\n        }\n\n        for (ColumnStatisticMetadata columnStatisticMetadata : statisticsMetadata.getColumnStatistics()) {\n            if (!useHistograms && columnStatisticMetadata.getStatisticType() == ColumnStatisticType.HISTOGRAM) {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/StatisticsAggregationPlanner.java#L77-L113","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (connector metadata)\ngetTableStatistics() -> [ROW_COUNT, MAX_VALUE_SIZE]\n// after\ngetTableStatistics() -> [ROW_COUNT]","handlingStrategy":"validation","validationCode":"// Check declared table statistic types before writes that collect stats\nList<TableStatisticType> types = getTableStatisticsMetadata(table).getTableStatistics();\nif (!new HashSet<>(types).equals(Set.of(TableStatisticType.ROW_COUNT))) {\n    throw new IllegalStateException(\"Only ROW_COUNT table statistics are supported: \" + types);\n}","typeGuard":"boolean supportsStatistics(TableStatisticType type) {\n    return type == TableStatisticType.ROW_COUNT;\n}","tryCatchPattern":"try {\n    executeCtasOrAnalyze(sql);\n} catch (PrestoException e) {\n    if (\"NOT_SUPPORTED\".equals(e.getErrorCode().getName()) && e.getMessage().startsWith(\"Table-wide statistic type not supported\")) {\n        throw new IllegalStateException(\"Disable extended table statistics or upgrade engine\", e);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["presto","planner","statistics","not-supported"],"backgroundTag":"unsupported-statistic-type","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}