{"record":{"id":"465876802b454627","repo":"prestodb/presto","slug":"invalid-window-frame","errorCode":"INVALID_WINDOW_FRAME","errorMessage":"Window frame start cannot be UNBOUNDED FOLLOWING","messagePattern":"Window frame start cannot be UNBOUNDED FOLLOWING","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java","lineNumber":4211,"sourceCode":"                    analyzeWindowFrame(window.getFrame().get());\n                }\n\n                FunctionKind kind = functionAndTypeResolver.getFunctionMetadata(analysis.getFunctionHandle(windowFunction)).getFunctionKind();\n                if (kind != AGGREGATE && kind != WINDOW) {\n                    throw new SemanticException(MUST_BE_WINDOW_FUNCTION, node, \"Not a window function: %s\", windowFunction.getName());\n                }\n            }\n\n            return windowFunctions;\n        }\n\n        private void analyzeWindowFrame(WindowFrame frame)\n        {\n            FrameBound.Type startType = frame.getStart().getType();\n            FrameBound.Type endType = frame.getEnd().orElseGet(() -> new FrameBound(CURRENT_ROW)).getType();\n\n            if (startType == UNBOUNDED_FOLLOWING) {\n                throw new SemanticException(INVALID_WINDOW_FRAME, frame, \"Window frame start cannot be UNBOUNDED FOLLOWING\");\n            }\n            if (endType == UNBOUNDED_PRECEDING) {\n                throw new SemanticException(INVALID_WINDOW_FRAME, frame, \"Window frame end cannot be UNBOUNDED PRECEDING\");\n            }\n            if ((startType == CURRENT_ROW) && (endType == PRECEDING)) {\n                throw new SemanticException(INVALID_WINDOW_FRAME, frame, \"Window frame starting from CURRENT ROW cannot end with PRECEDING\");\n            }\n            if ((startType == FOLLOWING) && (endType == PRECEDING)) {\n                throw new SemanticException(INVALID_WINDOW_FRAME, frame, \"Window frame starting from FOLLOWING cannot end with PRECEDING\");\n            }\n            if ((startType == FOLLOWING) && (endType == CURRENT_ROW)) {\n                throw new SemanticException(INVALID_WINDOW_FRAME, frame, \"Window frame starting from FOLLOWING cannot end with CURRENT ROW\");\n            }\n        }\n\n        private void analyzeHaving(QuerySpecification node, Scope scope)\n        {\n            if (node.getHaving().isPresent()) {","sourceCodeStart":4193,"sourceCodeEnd":4229,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java#L4193-L4229","documentation":"Analysis error from analyzeWindowFrame: the window frame's start bound was specified as UNBOUNDED FOLLOWING, which is logically incoherent (the frame cannot start at the end). Only a frame END may be unbounded following; the faulty input is the frame start specification in the OVER clause.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java:4211 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use UNBOUNDED PRECEDING or CURRENT ROW as the frame start","Swap the bounds: RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING","Omit the frame to use the default RANGE UNBOUNDED PRECEDING"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}