prestodb/presto · error · TableNotFoundException

Table not found

Error message

Table not found

What it means

Throws TableNotFoundException when the underlying Iceberg table can no longer be resolved while applying an index/scan for a table handle. The catalog metadata (table handle) became stale because the table was dropped or renamed between query planning and execution.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java:1756

                .map(IcebergColumnHandle.class::cast)
                .map(IcebergColumnHandle::getId)
                .collect(toImmutableSet());

        return Objects.equals(enforcedColumnIds, predicateColumnIds);
    }

    @Override
    public OptionalLong metadataDelete(ConnectorSession session, ConnectorTableHandle tableHandle, ConnectorTableLayoutHandle tableLayoutHandle)
    {
        IcebergTableHandle handle = (IcebergTableHandle) tableHandle;
        IcebergTableLayoutHandle layoutHandle = (IcebergTableLayoutHandle) tableLayoutHandle;

        Table icebergTable;
        try {
            icebergTable = getIcebergTable(session, handle.getSchemaTableName());
        }
        catch (Exception e) {
            throw new TableNotFoundException(handle.getSchemaTableName());
        }

        TupleDomain<IcebergColumnHandle> domainPredicate = layoutHandle.getValidPredicate();
        return removeScanFiles(handle, icebergTable, domainPredicate);
    }

    @Override
    public void setTableProperties(ConnectorSession session, ConnectorTableHandle tableHandle, Map<String, Object> properties)
    {
        IcebergTableHandle handle = (IcebergTableHandle) tableHandle;
        validateNoBranchSpecified(handle, "SET TABLE PROPERTIES");
        Table icebergTable = getIcebergTable(session, handle.getSchemaTableName());

        UpdateProperties updateProperties = icebergTable.updateProperties();
        for (Map.Entry<String, Object> entry : properties.entrySet()) {
            if (!tableProperties.getUpdatableProperties()
                    .contains(entry.getKey())) {
                throw new PrestoException(NOT_SUPPORTED, "Updating property " + entry.getKey() + " is not supported currently");

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Re-run the query to get a fresh table handle after the table is restored/recreated.
  2. Check that the table exists in the metastore: SELECT * FROM iceberg.information_schema.tables WHERE ... or SHOW CREATE TABLE.
  3. Avoid dropping/renaming tables while dependent queries are running.
  4. If a metastore outage caused it, verify connectivity and retry once the catalog is available.
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the table resolves before executing dependent logic
boolean exists = metadata.listTables(session, schemaName).contains(tableName);

Try / catch

try {
    applyScanFiles(handle);
} catch (TableNotFoundException e) {
    // table dropped/renamed mid-flight: re-acquire handle or abort gracefully
    logger.warn("Table %s no longer exists; refreshing handle", e.getTableName());
    handle = refreshTableHandle(handle);
}

Prevention

When it happens

Trigger: Calling removeScanFiles/layout application (IcebergAbstractMetadata:1756) where getIcebergTable(session, handle.getSchemaTableName()) fails because the table was dropped or renamed after the handle was created.

Common situations: Long-lived sessions or cached table handles referencing a dropped table; concurrent DROP TABLE while another query reads it; schema-registry or Glue/Hive metastore outages making the table temporarily unresolvable.

Related errors


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