prestodb/presto · warning · SQLFeatureNotSupportedException

cross reference not supported

Error message

cross reference not supported

What it means

getCrossReference() in PrestoDatabaseMetaData unconditionally throws SQLFeatureNotSupportedException ('cross reference not supported'). Cross-reference metadata (which keys of one table reference keys of another) cannot be provided because Presto has no foreign-key concept. The stub exists only to satisfy the DatabaseMetaData interface.

Source

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

    @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()
            throws SQLException
    {
        return select("" +
                "SELECT TYPE_NAME, DATA_TYPE, PRECISION, LITERAL_PREFIX, LITERAL_SUFFIX,\n" +
                "CREATE_PARAMS, NULLABLE, CASE_SENSITIVE, SEARCHABLE, UNSIGNED_ATTRIBUTE,\n" +
                "FIXED_PREC_SCALE, AUTO_INCREMENT, LOCAL_TYPE_NAME, MINIMUM_SCALE, MAXIMUM_SCALE,\n" +
                "SQL_DATA_TYPE, SQL_DATETIME_SUB, NUM_PREC_RADIX\n" +
                "FROM system.jdbc.types\n" +
                "ORDER BY DATA_TYPE");
    }

    @Override
    public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate)
            throws SQLException

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Do not request cross-reference metadata from Presto; treat all FK relations as absent
  2. Catch SQLFeatureNotSupportedException and return an empty result set
  3. Derive relationships from application-level knowledge or INFORMATION_SCHEMA if needed
  4. File/track upstream support if Presto ever exposes FK metadata

Example fix

// before
ResultSet xref = meta.getCrossReference(pc, ps, pt, fc, fs, ft);
// after
ResultSet xref;
try {
    xref = meta.getCrossReference(pc, ps, pt, fc, fs, ft);
} catch (SQLFeatureNotSupportedException e) {
    xref = EMPTY_RESULT_SET;
}
Defensive patterns

Strategy: try-catch

Validate before calling

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

Type guard

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

Try / catch

try (ResultSet rs = meta.getCrossReference(pc, ps, pt, fc, fs, ft)) { ... } catch (SQLFeatureNotSupportedException e) { /* no cross references */ }

Prevention

When it happens

Trigger: Calling DatabaseMetaData.getCrossReference(parentCatalog, parentSchema, parentTable, foreignCatalog, foreignSchema, foreignTable) on a Presto connection.

Common situations: Schema diffing tools, ER diagram tools, JDBC-aware IDEs comparing referential structure across catalogs.

Related errors


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