{"record":{"id":"7f823b35147e9e1c","repo":"prestodb/presto","slug":"malformed-hive-file-statistics","errorCode":"MALFORMED_HIVE_FILE_STATISTICS","errorMessage":"Invalid position: %d specified for FileStatistics page","messagePattern":"Invalid position: (.+?) specified for FileStatistics page","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveManifestUtils.java","lineNumber":87,"sourceCode":"        // fileSize   rowCount\n        //  X             X\n        PageBuilder statsPageBuilder = new PageBuilder(ImmutableList.of(BIGINT, BIGINT));\n        statsPageBuilder.declarePosition();\n        BIGINT.writeLong(statsPageBuilder.getBlockBuilder(FILE_SIZE_CHANNEL), fileSize);\n        BIGINT.writeLong(statsPageBuilder.getBlockBuilder(ROW_COUNT_CHANNEL), rowCount);\n\n        return statsPageBuilder.build();\n    }\n\n    public static long getFileSize(Page statisticsPage, int position)\n    {\n        // FileStatistics page layout:\n        //\n        // fileSize   rowCount\n        //  X             X\n\n        if (position < 0 || position >= statisticsPage.getPositionCount()) {\n            throw new PrestoException(MALFORMED_HIVE_FILE_STATISTICS, format(\"Invalid position: %d specified for FileStatistics page\", position));\n        }\n        return BIGINT.getLong(statisticsPage.getBlock(FILE_SIZE_CHANNEL), position);\n    }\n\n    public static Optional<Page> createPartitionManifest(PartitionUpdate partitionUpdate)\n    {\n        // Manifest Page layout:\n        //   fileName    fileSize\n        //      X           X\n        //      X           X\n        //      X           X\n        // ....\n        PageBuilder manifestBuilder = new PageBuilder(ImmutableList.of(VARCHAR, BIGINT));\n        BlockBuilder fileNameBuilder = manifestBuilder.getBlockBuilder(0);\n        BlockBuilder fileSizeBuilder = manifestBuilder.getBlockBuilder(1);\n        for (FileWriteInfo fileWriteInfo : partitionUpdate.getFileWriteInfos()) {\n            if (!fileWriteInfo.getFileSize().isPresent()) {\n                return Optional.empty();","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveManifestUtils.java#L69-L105","documentation":"getFileSize reads the FileStatistics manifest page (fileSize, rowCount columns); this guard fires when the requested position is outside the page's position count — a corrupt or wrongly indexed statistics page.","triggerScenarios":"Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveManifestUtils.java:87 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check position against the statistics page length before reading","Verify the fragment pages were produced with the expected layout"],"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"}