{"record":{"id":"6204f3e689bdcbae","repo":"prestodb/presto","slug":"not-supported-6204f3","errorCode":"NOT_SUPPORTED","errorMessage":"Offset support is not enabled","messagePattern":"Offset support is not enabled","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/ImplementOffset.java","lineNumber":82,"sourceCode":"    private final StandardFunctionResolution functionResolution;\n\n    public ImplementOffset(FunctionAndTypeManager functionAndTypeManager)\n    {\n        requireNonNull(functionAndTypeManager, \"functionAndTypeManager is null\");\n        this.functionResolution = new FunctionResolution(functionAndTypeManager.getFunctionAndTypeResolver());\n    }\n\n    @Override\n    public Pattern<OffsetNode> getPattern()\n    {\n        return PATTERN;\n    }\n\n    @Override\n    public Result apply(OffsetNode parent, Captures captures, Context context)\n    {\n        if (!isOffsetClauseEnabled(context.getSession())) {\n            throw new PrestoException(NOT_SUPPORTED, \"Offset support is not enabled\");\n        }\n\n        VariableReferenceExpression rowNumberSymbol = context.getVariableAllocator().newVariable(\"row_number\", BIGINT);\n\n        RowNumberNode rowNumberNode = new RowNumberNode(\n                parent.getSourceLocation(),\n                context.getIdAllocator().getNextId(),\n                parent.getSource(),\n                ImmutableList.of(),\n                rowNumberSymbol,\n                Optional.empty(),\n                false,\n                Optional.empty());\n\n        FilterNode filterNode = new FilterNode(\n                parent.getSourceLocation(),\n                context.getIdAllocator().getNextId(),\n                rowNumberNode,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/ImplementOffset.java#L64-L100","documentation":"OFFSET clauses are gated behind a feature flag. When the optimizer rule ImplementOffset fires on an OffsetNode but the session has offset-clause support disabled, it throws NOT_SUPPORTED instead of planning the offset.","triggerScenarios":"Executing a query with OFFSET (e.g. LIMIT 10 OFFSET 5) while the 'offset-clause-enabled' session property or config is false.","commonSituations":"Running OFFSET queries on a deployment where the feature flag was never enabled; upgrading Presto but not enabling the experimental flag; copy-pasting queries from a cluster where the flag is on.","solutions":["Enable the feature: SET SESSION offset_clause_enabled = true","Add offset-clause-enabled=true to the coordinator's config.properties","Rewrite the query using ROW_NUMBER() over an ordered subquery and filter row_number > offset"],"exampleFix":"// before\nSELECT * FROM t LIMIT 10 OFFSET 20;\n// after\nSELECT * FROM (\n  SELECT *, ROW_NUMBER() OVER () AS rn FROM t\n) WHERE rn > 20 LIMIT 10;","handlingStrategy":"try-catch","validationCode":"// check session property before issuing OFFSET query\nSHOW SESSION LIKE 'offset_clause_enabled';","typeGuard":"null","tryCatchPattern":"try {\n    return query(\"SELECT * FROM t LIMIT 10 OFFSET 20\");\n} catch (PrestoException e) {\n    if (e.getErrorCode() == NOT_SUPPORTED.toErrorCode()) {\n        return query(\"SELECT * FROM (SELECT *, ROW_NUMBER() OVER () rn FROM t) WHERE rn > 20 LIMIT 10\");\n    }\n    throw e;\n}","preventionTips":["Enable offset-clause-enabled=true in cluster config before using OFFSET","Avoid OFFSET in queries meant to run on clusters with feature flags off","Prefer keyset pagination over OFFSET for deep pagination anyway"],"tags":["sql","offset","feature-flag"],"backgroundTag":"feature-not-enabled","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"}