{"record":{"id":"7a28360ae8c7bf06","repo":"prestodb/presto","slug":"beforefirst","errorCode":null,"errorMessage":"beforeFirst","messagePattern":"beforeFirst","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java","lineNumber":643,"sourceCode":"    @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()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"first\");\n    }\n\n    @Override\n    public boolean last()","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java#L625-L661","documentation":"beforeFirst requires a scrollable cursor to rewind to the start of the result set; Presto results are forward-only server-side streams that cannot be repositioned, so the driver throws SQLFeatureNotSupportedException unconditionally. Re-reading a result set is impossible without re-executing the query.","triggerScenarios":"Calling rs.beforeFirst() to restart iteration over a PrestoResultSet, usually after consuming some rows.","commonSituations":"Code that iterates a ResultSet twice (e.g. once for headers, once for data); caching frameworks assuming scrollable results.","solutions":["Re-execute the statement (or run a new query) to iterate again","Consume the ResultSet once and buffer rows (List<T>) if multiple passes are needed","Restructure consumers to accept a single forward-only pass"],"exampleFix":"// before\nconsume(rs);\nrs.beforeFirst();\nconsumeAgain(rs);\n// after\nList<Row> rows = readAll(rs);\nconsume(rows);\nconsumeAgain(rows);","handlingStrategy":"try-catch","validationCode":"if (rs instanceof com.facebook.presto.jdbc.PrestoResultSet) {\n    throw new UnsupportedOperationException(\"beforeFirst is not supported; buffer rows or re-execute the query\");\n}","typeGuard":"boolean isPrestoResultSet(ResultSet rs) { return rs instanceof com.facebook.presto.jdbc.PrestoResultSet; }","tryCatchPattern":"try {\n    rs.beforeFirst();\n} catch (SQLFeatureNotSupportedException e) {\n    // re-run the statement or iterate a buffered List<Row>\n}","preventionTips":["Consume each Presto ResultSet exactly once","Buffer rows into collections for multi-pass consumption","Re-execute queries instead of rewinding cursors"],"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"}