prestodb/presto · error · SQLFeatureNotSupportedException

isAfterLast

Error message

isAfterLast

What it means

isAfterLast is a cursor-position query unsupported because PrestoResultSets are forward-only streams without tracked end-of-cursor state; the driver throws SQLFeatureNotSupportedException unconditionally. There is no scenario in which it returns a value.

Source

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

    @Override
    public BigDecimal getBigDecimal(String columnLabel)
            throws SQLException
    {
        return getBigDecimal(columnIndex(columnLabel));
    }

    @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()

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Track exhaustion yourself via the return value of rs.next()
  2. Buffer rows if post-iteration position checks are needed
  3. Avoid any cursor-position introspection APIs (isFirst/isLast/isAfterLast/isBeforeFirst) with Presto

Example fix

// before
while (rs.next()) {}
if (rs.isAfterLast()) { /* done */ }
// after
boolean consumed = false;
while (rs.next()) { consumed = true; processRow(rs); }
if (consumed) { /* done */ }
Defensive patterns

Strategy: try-catch

Validate before calling

if (rs instanceof com.facebook.presto.jdbc.PrestoResultSet) {
    // track row consumption manually via rs.next() return values
}

Type guard

boolean isPrestoResultSet(ResultSet rs) { return rs instanceof com.facebook.presto.jdbc.PrestoResultSet; }

Try / catch

try {
    boolean done = rs.isAfterLast();
} catch (SQLFeatureNotSupportedException e) {
    // infer completion from rs.next() returning false
}

Prevention

When it happens

Trigger: Calling rs.isAfterLast() on a PrestoResultSet, typically to detect that iteration consumed all rows.

Common situations: Porting scrollable-cursor logic from other JDBC drivers; loop guards written for MySQL/PostgreSQL result sets.

Related errors


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