prestodb/presto · error · SQLFeatureNotSupportedException
first
Error message
first
What it means
PrestoResultSet throws SQLFeatureNotSupportedException("first") because the driver only supports forward-only, read-once iteration over Presto query results. There is no row buffer, so jumping to the first row after iteration has started is impossible.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:657
@Override
public void beforeFirst()
throws SQLException
{
throw new SQLFeatureNotSupportedException("beforeFirst");
}
@Override
public void afterLast()
throws SQLException
{
throw new SQLFeatureNotSupportedException("afterLast");
}
@Override
public boolean first()
throws SQLException
{
throw new SQLFeatureNotSupportedException("first");
}
@Override
public boolean last()
throws SQLException
{
throw new SQLFeatureNotSupportedException("last");
}
@Override
public int getRow()
throws SQLException
{
throw new SQLFeatureNotSupportedException("getRow");
}
@Override
public boolean absolute(int row)View on GitHub (pinned to 55bb57d202)
Solutions
- Use rs.next() instead of rs.first() to test whether any rows exist
- Re-execute the query when you need to return to the first row
- Limit the query (LIMIT 1) and execute it again if only the first row is needed
- Buffer rows in a local collection to allow random access
Example fix
// before
if (rs.first()) { handle(rs); }
// after
if (rs.next()) { handle(rs); } Defensive patterns
Strategy: try-catch
Validate before calling
DatabaseMetaData md = conn.getMetaData(); boolean scrollable = md.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); // false for Presto
Try / catch
try { rs.first(); } catch (SQLFeatureNotSupportedException e) { /* use rs.next() to check for rows */ } Prevention
- Use rs.next() to test for a non-empty result set
- Re-run the query when the first row must be revisited
- Avoid scrollable-result-set idioms when targeting Presto
When it happens
Trigger: Calling ResultSet.first() on a PrestoResultSet, e.g. after using next() or when the caller expects a scrollable result set.
Common situations: Code that checks rs.first() to test for an empty result set, or legacy JDBC code written for MySQL/Oracle scrollable result sets being reused against Presto.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/0e2695b07367c990.
Report an issue: GitHub.