{"record":{"id":"eaff351cc8ef9141","repo":"prestodb/presto","slug":"islast","errorCode":null,"errorMessage":"isLast","messagePattern":"isLast","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java","lineNumber":636,"sourceCode":"    @Override\n    public boolean isAfterLast()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"isAfterLast\");\n    }\n\n    @Override\n    public boolean isFirst()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"isFirst\");\n    }\n\n    @Override\n    public boolean isLast()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"isLast\");\n    }\n\n    @Override\n    public void beforeFirst()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"beforeFirst\");\n    }\n\n    @Override\n    public void afterLast()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"afterLast\");\n    }\n\n    @Override\n    public boolean first()","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java#L618-L654","documentation":"isLast is unsupported for the same reason as the other position probes: Presto result sets are forward-only and cannot look ahead to detect the final row; PrestoResultSet throws SQLFeatureNotSupportedException unconditionally. Look-ahead semantics are incompatible with the streaming model.","triggerScenarios":"Calling rs.isLast() on a PrestoResultSet, commonly to avoid a trailing separator in generated output.","commonSituations":"CSV/JSON writers that need to know the last row; migration of scrollable-result-set logic to Presto.","solutions":["Track iteration manually: keep the previous row and emit it only when rs.next() returns true again (or use a 'hasNext' style two-variable loop)","Buffer rows into a collection and iterate by index","Remove separator logic dependence on cursor position"],"exampleFix":"// before\nwhile (rs.next()) { emit(rs); if (!rs.isLast()) emitSeparator(); }\n// after\nboolean first = true;\nwhile (rs.next()) { if (!first) emitSeparator(); emit(rs); first = false; }","handlingStrategy":"try-catch","validationCode":"if (rs instanceof com.facebook.presto.jdbc.PrestoResultSet) {\n    // emit separators based on your own iteration state, not isLast()\n}","typeGuard":"boolean isPrestoResultSet(ResultSet rs) { return rs instanceof com.facebook.presto.jdbc.PrestoResultSet; }","tryCatchPattern":"try {\n    boolean last = rs.isLast();\n} catch (SQLFeatureNotSupportedException e) {\n    // buffer rows or use a two-variable look-back loop\n}","preventionTips":["Implement separator/trailing logic with iteration state, not cursor probes","Buffer rows when look-ahead is required"],"tags":["jdbc","presto","unsupported-operation","cursor-position"],"backgroundTag":"jdbc-feature-not-supported","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}