prestodb/presto · error · PrestoException

ICEBERG_INVALID_METADATA

ICEBERG_INVALID_METADATA

Error message

Table is missing [%s] property: %s

What it means

Iceberg tables tracked in the Hive metastore must carry the metadata_location property pointing to their current Iceberg metadata JSON. If refresh finds the table is an Iceberg table but the property is absent, it throws ICEBERG_INVALID_METADATA 'Table is missing [metadata_location] property: <schema.table>', because it cannot locate the table metadata to load.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java:225

    {
        if (location.isPresent()) {
            refreshFromMetadataLocation(null);
            return currentMetadata;
        }

        Table table = getTable();

        if (!isIcebergTable(table)) {
            throw new UnknownTableTypeException("Not an Iceberg table: " + getSchemaTableName());
        }

        if (isPrestoView(table)) {
            throw new TableNotFoundException(new SchemaTableName(database, tableName));
        }

        String metadataLocation = table.getParameters().get(METADATA_LOCATION);
        if (metadataLocation == null) {
            throw new PrestoException(ICEBERG_INVALID_METADATA, format("Table is missing [%s] property: %s", METADATA_LOCATION, getSchemaTableName()));
        }

        refreshFromMetadataLocation(metadataLocation);

        return currentMetadata;
    }

    @Override
    public void commit(@Nullable TableMetadata base, TableMetadata metadata)
    {
        requireNonNull(metadata, "metadata is null");

        // if the metadata is already out of date, reject it
        if (!Objects.equals(base, current())) {
            throw new CommitFailedException("Cannot commit: stale table metadata for %s", getSchemaTableName());
        }

        // if the metadata is not changed, return early

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Set the property to a valid metadata JSON: ALTER TABLE ... SET TBLPROPERTIES ('metadata_location'='hdfs://.../v<N>.metadata.json') using the latest metadata file.
  2. Re-run the migration/conversion that originally registered the table with Iceberg metadata.
  3. Restore table parameters from metastore backup or a snapshot of the table definition.
  4. Audit ETL/metastore-mutating jobs to preserve unknown table parameters.

Example fix

-- before: table params missing metadata_location
-- after
ALTER TABLE iceberg.db.tbl SET TBLPROPERTIES ('metadata_location'='hdfs:///warehouse/db/tbl/metadata/00042-abc.metadata.json');
Defensive patterns

Strategy: validation

Validate before calling

Table t = metastore.getTable(db, name);
String loc = t.getParameters() == null ? null : t.getParameters().get("metadata_location");
if (loc == null || loc.isEmpty()) {
  throw new IllegalStateException("Table missing metadata_location: " + db + "." + name);
}

Type guard

boolean hasMetadataLocation(Table t) { return t != null && t.getParameters() != null && !Strings.isNullOrEmpty(t.getParameters().get("metadata_location")); }

Try / catch

try { ops.current(); } catch (PrestoException e) { if (e.getErrorCode().getCode() == ICEBERG_INVALID_METADATA.getCode()) { /* re-run migration or set metadata_location */ } throw e; }

Prevention

When it happens

Trigger: refresh (via current()/metadata()) on an Iceberg-marked Hive table whose parameters lack metadata_location — e.g. partially completed migration, external process stripping table parameters, or a manually created table missing the property.

Common situations: Interrupted Hive-to-Iceberg migration, metastore tools/ETL that rewrite table parameters without preserving metadata_location, manual CREATE TABLE mimicking Iceberg without registering metadata, metastore restore losing properties.

Related errors


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