prestodb/presto · error · SQLFeatureNotSupportedException

getRef

Error message

getRef

What it means

PrestoResultSet does not implement the JDBC Ref type: getRef is one of a family of sentinel methods that unconditionally throw SQLFeatureNotSupportedException, with the method name as the message. It fires whenever client code calls the unsupported accessor, not because of bad data.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:1102

    @Override
    public Statement getStatement()
    {
        return statement;
    }

    @Override
    public Object getObject(int columnIndex, Map<String, Class<?>> map)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("getObject");
    }

    @Override
    public Ref getRef(int columnIndex)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("getRef");
    }

    @Override
    public Blob getBlob(int columnIndex)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("getBlob");
    }

    @Override
    public Clob getClob(int columnIndex)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("getClob");
    }

    @Override
    public Array getArray(int columnIndex)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Remove REF handling from the Presto code path; model references as ordinary columns (IDs) and fetch them with SQL joins
  2. Skip REF columns in metadata-driven readers (check ResultSetMetaData.getColumnType != Types.REF)
  3. If object references are needed, resolve them with a second query instead of JDBC Ref objects

Example fix

// before
Ref ref = rs.getRef("owner");
Person owner = ref.getObject(Person.class);
// after
long ownerId = rs.getLong("owner_id");
Person owner = personDao.findById(ownerId);
Defensive patterns

Strategy: type-guard

Validate before calling

int type = rs.getMetaData().getColumnType(col);
if (type == java.sql.Types.REF
        || type == java.sql.Types.REF_CURSOR) {
    throw new IllegalStateException("REF not supported by Presto");
}

Type guard

static boolean isRefColumn(ResultSetMetaData md, int col) throws SQLException {
    return md.getColumnType(col) == Types.REF;
}

Try / catch

try {
    return rs.getRef(col);
} catch (SQLFeatureNotSupportedException e) {
    return null; // model reference via a plain ID column instead
}

Prevention

When it happens

Trigger: Calling rs.getRef(columnIndex) or getRef(columnLabel) on a PrestoResultSet.

Common situations: Code ported from Oracle (where REF columns exist); generic JDBC metadata-driven readers that probe for REF support; ORM mappings that include SqlRef fields.

Related errors


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