{"record":{"id":"ebb22a657e586a2c","repo":"prestodb/presto","slug":"isbeforefirst","errorCode":null,"errorMessage":"isBeforeFirst","messagePattern":"isBeforeFirst","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java","lineNumber":615,"sourceCode":"        if (value == null) {\n            return null;\n        }\n\n        return new BigDecimal(String.valueOf(value));\n    }\n\n    @Override\n    public BigDecimal getBigDecimal(String columnLabel)\n            throws SQLException\n    {\n        return getBigDecimal(columnIndex(columnLabel));\n    }\n\n    @Override\n    public boolean isBeforeFirst()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"isBeforeFirst\");\n    }\n\n    @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()","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java#L597-L633","documentation":"isBeforeFirst requires a scrollable/cursor-positioned ResultSet; Presto result sets are forward-only streams so the driver cannot know the cursor state and throws SQLFeatureNotSupportedException unconditionally. Presto's model never places the cursor in the 'before first' tracked state.","triggerScenarios":"Calling rs.isBeforeFirst() on a PrestoResultSet, often to test whether a query returned no rows before iterating.","commonSituations":"Code written against scrollable result sets (MySQL/PostgreSQL style) ported to Presto; checking for empty results before processing.","solutions":["Use rs.next() and check its boolean return to detect an empty result instead of isBeforeFirst","Collect rows into a list first if you need to know the row count up front","Do not request scrollable result sets — the driver ignores them and the position APIs are unsupported"],"exampleFix":"// before\nif (!rs.isBeforeFirst()) { /* empty result */ }\n// after\nif (!rs.next()) { /* empty result */ } else { do { processRow(rs); } while (rs.next()); }","handlingStrategy":"try-catch","validationCode":"if (rs instanceof com.facebook.presto.jdbc.PrestoResultSet) {\n    // empty-check must use rs.next(), not isBeforeFirst()\n}","typeGuard":"boolean isPrestoResultSet(ResultSet rs) { return rs instanceof com.facebook.presto.jdbc.PrestoResultSet; }","tryCatchPattern":"try {\n    boolean empty = !rs.isBeforeFirst();\n} catch (SQLFeatureNotSupportedException e) {\n    boolean empty = !rs.next();\n}","preventionTips":["Treat Presto result sets as forward-only: detect emptiness via the first rs.next() return","Never call cursor-position probes (isBeforeFirst/isFirst/isLast/isAfterLast) on Presto","Buffer rows when multiple passes or position awareness 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"}