prestodb/presto · warning · SQLFeatureNotSupportedException
primary keys not supported
Error message
primary keys not supported
What it means
PrestoDatabaseMetaData.getPrimaryKeys() unconditionally throws SQLFeatureNotSupportedException. Presto tables are not keyed relational tables in the JDBC sense; primary key metadata is not available from the engine, so the driver rejects the call rather than returning an empty set.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoDatabaseMetaData.java:1021
@Override
public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable)
throws SQLException
{
throw new SQLFeatureNotSupportedException("row identifiers not supported");
}
@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)View on GitHub (pinned to 55bb57d202)
Solutions
- Catch SQLFeatureNotSupportedException and treat tables as keyless
- Derive keys from table properties/comments or your own schema definitions if applicable
- Configure the code generator to work without primary keys (natural keys or no key strategy)
Defensive patterns
Strategy: try-catch
Validate before calling
if (md.getDatabaseProductName().contains("Presto")) {
return Collections.emptyList(); // no primary key metadata
} Try / catch
try (ResultSet rs = md.getPrimaryKeys(catalog, schema, table)) {
return readPrimaryKeys(rs);
} catch (SQLFeatureNotSupportedException e) {
return Collections.emptyList();
} Prevention
- Configure code generators to run without primary key metadata for Presto
- Skip getPrimaryKeys in generic metadata crawlers
- Model keys via table properties/comments and read those instead
When it happens
Trigger: Calling DatabaseMetaData.getPrimaryKeys(catalog, schema, table); schema tools and ORMs discovering primary keys for entity mapping or join inference.
Common situations: Code generators (jOOQ, Hibernate reverse engineering) expecting PK metadata; ER-diagram tools; data cataloging tools importing schema from JDBC.
Related errors
- privileges not supported
- row identifiers not supported
- version columns not supported
- Result set type must be TYPE_FORWARD_ONLY
- Result set concurrency must be CONCUR_READ_ONLY
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/2ef95e9579c0e7aa.
Report an issue: GitHub.