prestodb/presto · error · PrestoException

MALFORMED_HIVE_FILE_STATISTICS

MALFORMED_HIVE_FILE_STATISTICS

Error message

Invalid position: %d specified for FileStatistics page

What it means

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.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveManifestUtils.java:87

        // fileSize   rowCount
        //  X             X
        PageBuilder statsPageBuilder = new PageBuilder(ImmutableList.of(BIGINT, BIGINT));
        statsPageBuilder.declarePosition();
        BIGINT.writeLong(statsPageBuilder.getBlockBuilder(FILE_SIZE_CHANNEL), fileSize);
        BIGINT.writeLong(statsPageBuilder.getBlockBuilder(ROW_COUNT_CHANNEL), rowCount);

        return statsPageBuilder.build();
    }

    public static long getFileSize(Page statisticsPage, int position)
    {
        // FileStatistics page layout:
        //
        // fileSize   rowCount
        //  X             X

        if (position < 0 || position >= statisticsPage.getPositionCount()) {
            throw new PrestoException(MALFORMED_HIVE_FILE_STATISTICS, format("Invalid position: %d specified for FileStatistics page", position));
        }
        return BIGINT.getLong(statisticsPage.getBlock(FILE_SIZE_CHANNEL), position);
    }

    public static Optional<Page> createPartitionManifest(PartitionUpdate partitionUpdate)
    {
        // Manifest Page layout:
        //   fileName    fileSize
        //      X           X
        //      X           X
        //      X           X
        // ....
        PageBuilder manifestBuilder = new PageBuilder(ImmutableList.of(VARCHAR, BIGINT));
        BlockBuilder fileNameBuilder = manifestBuilder.getBlockBuilder(0);
        BlockBuilder fileSizeBuilder = manifestBuilder.getBlockBuilder(1);
        for (FileWriteInfo fileWriteInfo : partitionUpdate.getFileWriteInfos()) {
            if (!fileWriteInfo.getFileSize().isPresent()) {
                return Optional.empty();

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check position against the statistics page length before reading
  2. Verify the fragment pages were produced with the expected layout
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveManifestUtils.java:87 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/7f823b35147e9e1c. Report an issue: GitHub.