prestodb/presto · error · UnknownTableTypeException

Not an Iceberg table:

Error message

Not an Iceberg table: 

What it means

tableExists() in IcebergHiveMetadata checks whether a metastore table is an Iceberg table. If the Hive table exists in the metastore but is NOT an Iceberg table (and not a Presto view), Presto throws UnknownTableTypeException to signal the table exists but is managed by a different connector (e.g. native Hive). This prevents the Iceberg connector from silently operating on a foreign table.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java:276

                columns,
                tableProperties,
                comment);

        return Optional.of(new IcebergViewMetadata(table.getParameters(), tableMetadata));
    }

    @Override
    protected boolean tableExists(ConnectorSession session, SchemaTableName schemaTableName)
    {
        Optional<Table> hiveTable = getHiveTable(session, schemaTableName);
        if (!hiveTable.isPresent()) {
            return false;
        }
        if (isPrestoView(hiveTable.get())) {
            return false;
        }
        if (!isIcebergTable(hiveTable.get())) {
            throw new UnknownTableTypeException("Not an Iceberg table: " + schemaTableName);
        }
        return true;
    }

    private Optional<Table> getHiveTable(ConnectorSession session, SchemaTableName schemaTableName)
    {
        IcebergTableName name = IcebergTableName.from(schemaTableName.getTableName());
        return metastore.getTable(getMetastoreContext(session), schemaTableName.getSchemaName(), name.getTableName());
    }

    @Override
    public List<String> listSchemaNames(ConnectorSession session)
    {
        return metastore.getAllDatabases(getMetastoreContext(session));
    }

    @Override
    public Map<String, Object> getSchemaProperties(ConnectorSession session, CatalogSchemaName schemaName)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the table is actually an Iceberg table (has 'table_type'='ICEBERG' or metadata_location property) via SHOW CREATE TABLE in the Hive connector
  2. Query the table through the correct connector/catalog (e.g. hive.<schema>.<table> instead of iceberg.<schema>.<table>)
  3. If the table should be Iceberg, migrate it with a proper Hive-to-Iceberg migration tool rather than querying it directly
  4. If the table is stale/leftover, drop it from the metastore with the owning connector and recreate as Iceberg

Example fix

// before
SELECT * FROM iceberg.sales.orders; -- UnknownTableTypeException
// after
SELECT * FROM hive.sales.orders; -- route to the owning connector
Defensive patterns

Strategy: validation

Validate before calling

-- Before querying via the Iceberg catalog, confirm ownership:
SHOW TABLES FROM hive.<schema>;  -- if the table lives here, use the hive catalog
SELECT * FROM system.metadata.table_comments WHERE schema_name='<schema>';

Type guard

// Java-side guard mirroring the connector logic
boolean isIcebergTable(io.prestodb.spi.connector.ConnectorTableHandle handle) {
    return handle instanceof IcebergTableHandle;
}

Try / catch

try {
    connection.createStatement().executeQuery("SELECT * FROM iceberg.sales.orders");
} catch (SQLException e) {
    if (e.getMessage() != null && e.getMessage().contains("Not an Iceberg table")) {
        // reroute to hive catalog or migrate the table
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling any Iceberg catalog/describe/query operation on a table that exists in the Hive metastore but was created by the Hive connector or another engine; the isIcebergTable(hiveTable.get()) check fails because table properties lack the Iceberg metadata pointers.

Common situations: Migrating tables between Hive and Iceberg connectors; pointing the Iceberg connector at a schema containing legacy Hive tables; a table was dropped and recreated as a plain Hive table; misconfigured catalog so a query lands on the wrong connector.

Related errors


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