{"record":{"id":"a022609684153a92","repo":"risingwavelabs/risingwave","slug":"physical-next-in-a-match-recognize-define-is-not-s","errorCode":null,"errorMessage":"physical NEXT in a MATCH_RECOGNIZE DEFINE is not supported","messagePattern":"physical NEXT in a MATCH_RECOGNIZE DEFINE is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/executor/match_recognize/executor.rs","lineNumber":372,"sourceCode":"        let condition = build_non_strict_from_prost(\n            pb.condition\n                .as_ref()\n                .ok_or_else(|| anyhow::anyhow!(\"MATCH_RECOGNIZE define missing condition\"))?,\n            error_report,\n        )?;\n        let slots = pb\n            .slots\n            .iter()\n            .map(|s| {\n                let kind = s.kind();\n                // The binder rejects physical NEXT in DEFINE (a verdict depending on rows after\n                // the candidate needs per-candidate decidability), so no plan this frontend\n                // produces carries it — reject rather than evaluate a watermark-unsafe,\n                // arrival-order-dependent read from a skewed plan. UNSPECIFIED (also what an\n                // out-of-range wire value decodes to) fails fast rather than silently changing\n                // the predicate's meaning. Every later match on the kind relies on this.\n                if kind == DefineSlotKind::Next {\n                    return Err(StreamExecutorError::from(anyhow::anyhow!(\n                        \"physical NEXT in a MATCH_RECOGNIZE DEFINE is not supported\"\n                    )));\n                }\n                if kind == DefineSlotKind::Unspecified {\n                    return Err(StreamExecutorError::from(anyhow::anyhow!(\n                        \"invalid MATCH_RECOGNIZE define slot kind: {}\",\n                        s.kind\n                    )));\n                }\n                Ok(DefineSlot {\n                    kind,\n                    vars: s.vars.clone(),\n                    col_idx: s.col_idx as usize,\n                    offset: s.offset as usize,\n                })\n            })\n            .collect::<StreamExecutorResult<Vec<_>>>()?;\n        Ok(CompiledDefine {","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/executor/match_recognize/executor.rs#L354-L390","documentation":"A MATCH_RECOGNIZE DEFINE slot declares the physical NEXT kind, i.e. a direct read of the next row. This is watermark-unsafe and arrival-order-dependent and no plan the frontend produces should carry it, so the executor rejects it outright rather than evaluating a skewed predicate.","triggerScenarios":"DefineSlot::from_protobuf sees kind == DefineSlotKind::Next, from a corrupt/hand-modified plan or a non-standard frontend emitting NEXT.","commonSituations":"Custom or experimental frontend emitting NEXT defines; hand-crafted protobufs in tests; plan corruption in meta storage.","solutions":["Remove the NEXT-based DEFINE from the plan and express the logic with supported pattern/define constructs.","Regenerate the plan with the standard frontend (re-create the query/MV).","Fix any custom tooling that emits DefineSlotKind::Next in plan protobufs."],"exampleFix":"// before\nPbDefineSlot { kind: DefineSlotKind::Next as i32, .. }\n// after\nPbDefineSlot { kind: DefineSlotKind::Expr as i32, .. }","handlingStrategy":"validation","validationCode":"// Reject NEXT defines before sending the plan to the backend:\nif s.kind() == DefineSlotKind::Next {\n    return Err(anyhow!(\"NEXT define is not supported; rewrite the pattern\"));\n}","typeGuard":null,"tryCatchPattern":"// Surface an unsupported-plan error to the user instead of an internal failure:\nmatch define_from_protobuf(&pb) {\n    Err(e) if e.to_string().contains(\"physical NEXT\") => {\n        return user_facing_unsupported_feature_error(e);\n    }\n    r => r,\n}","preventionTips":["Never emit DefineSlotKind::Next from custom planners or tooling.","Validate generated plans against supported DefineSlotKind values before submission.","Document NEXT as unsupported in any MATCH_RECOGNIZE tooling."],"tags":["match-recognize","unsupported-feature","plan-deserialization"],"backgroundTag":"unsupported-operation","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}