{"record":{"id":"3e49742ea345262b","repo":"risingwavelabs/risingwave","slug":"match-recognize-define-missing-condition","errorCode":null,"errorMessage":"MATCH_RECOGNIZE define missing condition","messagePattern":"MATCH_RECOGNIZE define missing condition","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/executor/match_recognize/executor.rs","lineNumber":357,"sourceCode":"    offset: usize,\n}\n\n/// A `DEFINE` predicate compiled for execution: a boolean condition over a synthetic slot row.\npub struct CompiledDefine {\n    symbol: String,\n    condition: NonStrictExpression,\n    slots: Vec<DefineSlot>,\n}\n\nimpl CompiledDefine {\n    pub fn from_protobuf(\n        pb: &PbMatchRecognizeDefine,\n        error_report: impl EvalErrorReport + 'static,\n    ) -> StreamExecutorResult<Self> {\n        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                }","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/executor/match_recognize/executor.rs#L339-L375","documentation":"When deserializing a MATCH_RECOGNIZE DEFINE slot from protobuf, the condition expression (`pb.condition`) is absent. Each DEFINE row pattern needs a concrete boolean condition to evaluate candidates, so the executor fails deserialization rather than building a define that matches everything.","triggerScenarios":"DefineSlot::from_protobuf called with a PbMatchRecognizeDefine whose condition field is None.","commonSituations":"Corrupt or hand-edited plan protobuf; frontend/backend version skew losing the field; manually built prost messages in tests.","solutions":["Re-create the query/MV so the frontend regenerates a complete plan.","Check for version skew between frontend and stream compute and upgrade consistently.","When crafting protobufs in tests, always set condition on DEFINE slots."],"exampleFix":"// before\nPbMatchRecognizeDefine { slots: ..., condition: None }\n// after\nPbMatchRecognizeDefine { slots: ..., condition: Some(condition_proto) }","handlingStrategy":"validation","validationCode":"// Validate before building the define slot:\nif define.condition.is_none() {\n    return Err(anyhow!(\"DEFINE '{}' has no condition\", define.pattern));\n}","typeGuard":null,"tryCatchPattern":"// Catch missing-condition at plan load and regenerate:\nmatch DefineSlot::from_protobuf(&pb, &report) {\n    Err(e) if e.to_string().contains(\"define missing condition\") => re_plan_or_recreate_job(),\n    r => r,\n}","preventionTips":["Always emit a condition for every DEFINE pattern in the frontend.","Use builder helpers that make condition required.","Round-trip test DEFINE protobufs."],"tags":["match-recognize","protobuf","plan-deserialization"],"backgroundTag":"missing-required-argument","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}