prestodb/presto · warning · SQLFeatureNotSupportedException

imported keys not supported

Error message

imported keys not supported

What it means

getImportedKeys() in PrestoDatabaseMetaData is unimplemented and unconditionally throws SQLFeatureNotSupportedException with message 'imported keys not supported'. Presto's SQL engine does not expose foreign-key metadata, so the JDBC driver cannot report which keys a table imports. Any JDBC tool that calls this metadata method will fail.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoDatabaseMetaData.java:1028

    @Override
    public ResultSet getVersionColumns(String catalog, String schema, String table)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("version columns not supported");
    }

    @Override
    public ResultSet getPrimaryKeys(String catalog, String schema, String table)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("primary keys not supported");
    }

    @Override
    public ResultSet getImportedKeys(String catalog, String schema, String table)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("imported keys not supported");
    }

    @Override
    public ResultSet getExportedKeys(String catalog, String schema, String table)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("exported keys not supported");
    }

    @Override
    public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("cross reference not supported");
    }

    @Override
    public ResultSet getTypeInfo()

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Avoid calling getImportedKeys on Presto; Presto tables have no enforced foreign keys, so treat the result as an empty set in caller code
  2. Catch SQLFeatureNotSupportedException and return an empty ResultSet-like structure / skip FK processing
  3. Use a metadata bridge (e.g. query INFORMATION_SCHEMA.TABLES/COLUMNS) instead of JDBC FK metadata
  4. File/track the upstream TODO to implement the method if FK metadata becomes available

Example fix

// before
ResultSet fk = meta.getImportedKeys(catalog, schema, table);
// after
ResultSet fk;
try {
    fk = meta.getImportedKeys(catalog, schema, table);
} catch (SQLFeatureNotSupportedException e) {
    fk = EMPTY_RESULT_SET; // Presto has no foreign keys
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Presto never supports FK metadata; gate the call
databaseMetaDataCapability = (meta instanceof com.facebook.presto.jdbc.PrestoDatabaseMetaData) ? false : true;

Type guard

boolean supportsImportedKeys = !(meta instanceof com.facebook.presto.jdbc.PrestoDatabaseMetaData);

Try / catch

try (ResultSet rs = meta.getImportedKeys(cat, schema, table)) { ... } catch (SQLFeatureNotSupportedException e) { /* treat as no foreign keys */ }

Prevention

When it happens

Trigger: Calling DatabaseMetaData.getImportedKeys(catalog, schema, table) on a PrestoConnection, e.g. from an IDE schema browser or an ORM that inspects foreign keys.

Common situations: IntelliJ/Eclipse/DBeaver table introspection, Hibernate/JPA schema validation or reverse engineering, migration tools that map referential integrity.

Related errors


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