{"record":{"id":"92bcfbb39eee2f79","repo":"risingwavelabs/risingwave","slug":"match-recognize-within-span-predicate-has-type","errorCode":null,"errorMessage":"MATCH_RECOGNIZE WITHIN span predicate has type {}, expected boolean","messagePattern":"MATCH_RECOGNIZE WITHIN span predicate has type (.+?), expected boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/from_proto/match_recognize.rs","lineNumber":204,"sourceCode":"                    order_key_indices[0],\n                    input.schema().len()\n                )\n            })?;\n        if let Some(deadline) = &within_deadline\n            && deadline.return_type() != order_key_type\n        {\n            return Err(anyhow::anyhow!(\n                \"MATCH_RECOGNIZE WITHIN deadline has type {} but the ORDER BY column has type {}; \\\n                 the two are compared directly\",\n                deadline.return_type(),\n                order_key_type,\n            )\n            .into());\n        }\n        if let Some(predicate) = &within\n            && predicate.return_type() != DataType::Boolean\n        {\n            return Err(anyhow::anyhow!(\n                \"MATCH_RECOGNIZE WITHIN span predicate has type {}, expected boolean\",\n                predicate.return_type(),\n            )\n            .into());\n        }\n\n        let vnode_bitmap = params.vnode_bitmap.clone().map(std::sync::Arc::new);\n        let state_table_catalog = node\n            .state_table\n            .as_ref()\n            .ok_or_else(|| anyhow::anyhow!(\"MATCH_RECOGNIZE node missing its state table\"))?;\n        let state_table =\n            StateTableBuilder::new(state_table_catalog, store.clone(), vnode_bitmap.clone())\n                .forbid_preload_all_rows()\n                .build()\n                .await;\n        let exec = MatchRecognizeExecutor::new(MatchRecognizeExecutorArgs {\n            ctx: params.actor_context,","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/from_proto/match_recognize.rs#L186-L222","documentation":"The `within` field must be a boolean span predicate evaluated per candidate row. The decoder found a non-boolean expression type and rejects the plan, since a non-boolean predicate cannot drive the span window logic.","triggerScenarios":"`new_boxed_executor` decodes a MatchRecognizeNode whose `within` expression's `return_type()` is not `DataType::Boolean` — e.g. the binder produced a raw column or arithmetic expression instead of a comparison.","commonSituations":"Writing `WITHIN <expr>` where `<expr>` is not a boolean condition (e.g. a column or numeric literal); frontend/binder bugs failing to wrap the expression in a comparison; version skew changing expression typing.","solutions":["Ensure the WITHIN expression is a boolean condition, e.g. `WITHIN (ts > now() - INTERVAL '1 hour')` rather than a bare column.","Re-create the streaming job so the current binder regenerates the predicate.","Align node versions to rule out version skew.","If the SQL predicate is clearly boolean yet fails, report a binder bug."],"exampleFix":"-- before\nMATCH_RECOGNIZE ( ORDER BY ts WITHIN ts ... )\n-- after\nMATCH_RECOGNIZE ( ORDER BY ts WITHIN ts >= now() - INTERVAL '1 hour' ... )","handlingStrategy":"validation","validationCode":"// SQL-level guard: WITHIN must be a boolean expression\n-- write WITHIN (<boolean condition>), e.g. WITHIN (ts >= now() - INTERVAL '1 hour')","typeGuard":null,"tryCatchPattern":"// Pre-check decoded predicate type\nif let Some(p) = &within && p.return_type() != DataType::Boolean {\n    return Err(anyhow!(\"WITHIN predicate must be boolean, got {}\", p.return_type()));\n}","preventionTips":["Always express WITHIN as a boolean condition, never a bare column or value.","Check EXPLAIN output to confirm the predicate's inferred type is boolean.","Add frontend tests covering non-boolean WITHIN inputs."],"tags":["streaming","match-recognize","type-mismatch","predicate"],"backgroundTag":"type-mismatch","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"}