prestodb/presto · error · TableNotFoundException

Table not found: ${new SchemaTableName(database, tableName)}

Error message

Table not found: ${new SchemaTableName(database, tableName)}

What it means

During refresh, after confirming the table is an Iceberg table, Presto checks whether the Hive table is actually a Presto view; if so it throws TableNotFoundException with 'Table not found: <schema.table>'. This makes Iceberg operations on Presto-defined views behave as if the table does not exist.

Source

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

        return currentMetadata;
    }

    @Override
    public TableMetadata refresh()
    {
        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

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use the catalog where the view is defined (usually hive) to query the view.
  2. Rename the view or the table to avoid shadowing in the Iceberg catalog namespace.
  3. Verify with SHOW CREATE TABLE / metastore inspection which object the name refers to.
  4. Create the Iceberg table if it is genuinely missing and only the view exists.

Example fix

-- before: SELECT * FROM iceberg.default.my_view; -- Table not found
-- after
SELECT * FROM hive.default.my_view;
Defensive patterns

Strategy: validation

Validate before calling

Table t = metastore.getTable(db, name);
if (t == null || isPrestoView(t)) {
  throw new TableNotFoundException(new SchemaTableName(db, name));
}

Type guard

boolean isRealTable(Table t) { return t != null && t.getTableType() != null && t.getTableType().equals(TableType.EXTERNAL_TABLE.toString()) && !isPrestoView(t); }

Try / catch

try { icebergOps.refresh(); } catch (TableNotFoundException e) { /* route query to hive catalog or fail with clear message */ }

Prevention

When it happens

Trigger: Calling refresh (via current()/metadata()) on a schema.table that resolves in the metastore to a Presto view (isPrestoView true) — e.g. a view name passed where a table is expected, or name shadowing between a view and intended Iceberg table.

Common situations: Views created via the Hive connector being accessed through the Iceberg connector, reusing a dropped table's name for a view, typos that resolve to an existing view instead of the intended table.

Related errors


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