prestodb/presto · error · PrestoException

ICEBERG_INVALID_METADATA

ICEBERG_INVALID_METADATA

Error message

Cannot read manifest files. Manifests may be written by a newer Iceberg version.

What it means

SnapshotsTable.buildPages reads Iceberg manifest files (Avro) to build the $manifests/$snapshots metadata table. If manifest deserialization throws an Avro-related RuntimeException, the connector wraps it in a PrestoException with ICEBERG_INVALID_METADATA, signaling the metadata was produced by an incompatible (likely newer) Iceberg writer.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/SnapshotsTable.java:123

    private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, ConnectorSession session, Table icebergTable)
    {
        PageListBuilder pagesBuilder = PageListBuilder.forTable(tableMetadata);
        RuntimeStats runtimeStats = session.getRuntimeStats();
        TableScan tableScan = buildTableScan(icebergTable, SNAPSHOTS, runtimeStats);
        TimeZoneKey timeZoneKey = session.getTimeZoneKey();

        Map<String, Integer> columnNameToPosition = columnNameToPositionInSchema(tableScan.schema());

        try (CloseableIterable<FileScanTask> fileScanTasks = tableScan.planFiles()) {
            fileScanTasks.forEach(fileScanTask -> addRows((DataTask) fileScanTask, pagesBuilder, timeZoneKey, columnNameToPosition));
        }
        catch (IOException e) {
            throw new UncheckedIOException(e);
        }
        catch (RuntimeException e) {
            // Catch Avro-specific exceptions that may occur during manifest deserialization
            if (isAvroException(e)) {
                throw new PrestoException(ICEBERG_INVALID_METADATA,
                        "Cannot read manifest files. Manifests may be written by a newer Iceberg version.", e);
            }
            throw e;
        }

        return pagesBuilder.build();
    }

    private static boolean checkNonNull(Object object, PageListBuilder pagesBuilder)
    {
        if (object == null) {
            pagesBuilder.appendNull();
            return false;
        }
        return true;
    }

    private static void addRows(DataTask dataTask, PageListBuilder pagesBuilder, TimeZoneKey timeZoneKey, Map<String, Integer> columnNameToPositionInSchema)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Upgrade Presto/Trino to a version bundling an Iceberg/Avro library compatible with the writer version that produced the manifests
  2. Downgrade or re-pin the writing engine's Iceberg version to match what Presto can read
  3. Rewrite the table metadata with the older writer (e.g. rewrite_manifests / rewrite_data_files) so manifests are re-encoded in a readable format
  4. Inspect the wrapped Avro exception (the PrestoException's cause) to confirm which schema/field is incompatible
Defensive patterns

Strategy: try-catch

Validate before calling

// Check the Iceberg writer version in table metadata before querying manifests metadata tables
// e.g. compare format-version / writer-version against the connector's supported version

Try / catch

try {
    // query table$manifests / $snapshots
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("ICEBERG_INVALID_METADATA")) {
        // manifests written by newer Iceberg; fall back or upgrade connector
    } else { throw e; }
}

Prevention

When it happens

Trigger: Querying a metadata table (e.g. "table$manifests" or "$snapshots") whose manifest list/manifest files were written by a newer Iceberg version whose Avro schema the bundled reader cannot deserialize.

Common situations: Cluster upgraded its Iceberg writing library (Spark/Iceberg runtime) but Presto's bundled Iceberg/Avro libraries are older; reading a table written by a newer Iceberg release; mixed-version environments.

Related errors


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