{"record":{"id":"c384e9b0e681fa70","repo":"prestodb/presto","slug":"stripe-at-offset-s-has-unexpected-flat-map-value","errorCode":null,"errorMessage":"Stripe at offset %s has unexpected flat map value node column stats with non-zero number of values","messagePattern":"Stripe at offset (.+?) has unexpected flat map value node column stats with non-zero number of values","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/OrcWriteValidation.java","lineNumber":355,"sourceCode":"            throw new OrcCorruptionException(orcDataSourceId, \"Could not find stripe statistics for a stripe at offset %s\", stripeOffset);\n        }\n\n        List<ColumnStatistics> allStripeColumnStatistics = stripeStats.getColumnStatistics();\n        Set<Integer> excludedNodes = new HashSet<>();\n        for (Entry<Integer, Integer> keyToMapNodeEntry : flattenedKeyToMapNodes.entrySet()) {\n            int keyNode = keyToMapNodeEntry.getKey();\n\n            ColumnStatistics stripeColumnStat = allStripeColumnStatistics.get(keyNode);\n            if (stripeColumnStat.getNumberOfValues() == 0) {\n                // This flat map column writer didn't write any key/value.\n                // Go over all value nodes for this flat map and check that they\n                // have 0 values before marking them as excluded.\n                Integer mapNode = keyToMapNodeEntry.getValue();\n                Set<Integer> valueNodes = flattenedMapToValueNodes.get(mapNode);\n                for (int valueNode : valueNodes) {\n                    ColumnStatistics valueColumnStat = allStripeColumnStatistics.get(valueNode);\n                    if (valueColumnStat.getNumberOfValues() != 0) {\n                        throw new OrcCorruptionException(\n                                orcDataSourceId,\n                                \"Stripe at offset %s has unexpected flat map value node column stats with non-zero number of values\",\n                                stripeOffset);\n                    }\n                    excludedNodes.add(valueNode);\n                }\n            }\n        }\n\n        // return original stats excluding the flat map value stats for empty flat maps\n        return stats.entrySet().stream()\n                .filter(e -> !excludedNodes.contains(e.getKey()))\n                .collect(toImmutableMap(Entry::getKey, Entry::getValue));\n    }\n\n    private Map<Integer, ColumnStatistics> aggregateRowGroupStatisticsFromRowIndex(\n            OrcDataSourceId orcDataSourceId,\n            Map<StreamId, List<RowGroupIndex>> actualRowGroupStatistics,","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/OrcWriteValidation.java#L337-L373","documentation":"Write-validation error specific to flattened maps: a flat map's value-node column statistics report a non-zero number of values, which is inconsistent with the flattened-map writer's expectations for the recorded key set. An invariant check while adjusting row-group stats; flags writer/statistics inconsistency.","triggerScenarios":"Thrown at presto-orc/src/main/java/com/facebook/presto/orc/OrcWriteValidation.java:355 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report as a Presto ORC writer bug with the validation stack trace","Rewrite the data without flat-map optimization as a workaround","Confirm flat-map reader/writer versions match"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}