prestodb/presto · error · SQLFeatureNotSupportedException
isFirst
Error message
isFirst
What it means
isFirst cannot be answered by the Presto driver because its result sets are forward-only streams with no absolute row positioning; PrestoResultSet throws SQLFeatureNotSupportedException unconditionally. The capability simply does not exist in this driver.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:629
@Override
public boolean isBeforeFirst()
throws SQLException
{
throw new SQLFeatureNotSupportedException("isBeforeFirst");
}
@Override
public boolean isAfterLast()
throws SQLException
{
throw new SQLFeatureNotSupportedException("isAfterLast");
}
@Override
public boolean isFirst()
throws SQLException
{
throw new SQLFeatureNotSupportedException("isFirst");
}
@Override
public boolean isLast()
throws SQLException
{
throw new SQLFeatureNotSupportedException("isLast");
}
@Override
public void beforeFirst()
throws SQLException
{
throw new SQLFeatureNotSupportedException("beforeFirst");
}
@Override
public void afterLast()View on GitHub (pinned to 55bb57d202)
Solutions
- Use a boolean/counter flag set when the first rs.next() succeeds
- If first/last distinctions matter, materialize the rows into a List first
- Never rely on cursor-position APIs against Presto result sets
Example fix
// before
while (rs.next()) { if (rs.isFirst()) renderHeader(); renderRow(rs); }
// after
boolean first = true;
while (rs.next()) { if (first) { renderHeader(); first = false; } renderRow(rs); } Defensive patterns
Strategy: try-catch
Validate before calling
if (rs instanceof com.facebook.presto.jdbc.PrestoResultSet) {
// maintain a first-row flag yourself
} Type guard
boolean isPrestoResultSet(ResultSet rs) { return rs instanceof com.facebook.presto.jdbc.PrestoResultSet; } Try / catch
try {
boolean first = rs.isFirst();
} catch (SQLFeatureNotSupportedException e) {
// maintain your own row counter/flag
} Prevention
- Use boolean flags or row counters instead of position queries
- Materialize rows into a List when positional logic is unavoidable
When it happens
Trigger: Calling rs.isFirst() on a PrestoResultSet, often in row-number-sensitive processing logic.
Common situations: Rendering code that special-cases the first row; frameworks migrated from scrollable result-set drivers.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/cf6e914fce1f7671.
Report an issue: GitHub.