{"record":{"id":"dd350c4cca61c572","repo":"risingwavelabs/risingwave","slug":"batchmatchrecognize-is-not-implemented-yet","errorCode":null,"errorMessage":"BatchMatchRecognize is not implemented yet","messagePattern":"BatchMatchRecognize is not implemented yet","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/logical_match_recognize.rs","lineNumber":195,"sourceCode":"        self.core.visit_exprs(v);\n    }\n}\n\nimpl PredicatePushdown for LogicalMatchRecognize {\n    fn predicate_pushdown(\n        &self,\n        predicate: Condition,\n        ctx: &mut PredicatePushdownContext,\n    ) -> PlanRef {\n        // Output columns are computed (partition/measures), so do not push predicates through, but\n        // keep recursing so a share below this node receives a contribution from every parent.\n        gen_filter_and_pushdown(self, predicate, Condition::true_cond(), ctx)\n    }\n}\n\nimpl ToBatch for LogicalMatchRecognize {\n    fn to_batch(&self) -> Result<super::BatchPlanRef> {\n        bail!(\"BatchMatchRecognize is not implemented yet\")\n    }\n}\n\nimpl ToStream for LogicalMatchRecognize {\n    fn to_stream(&self, ctx: &mut ToStreamContext) -> Result<super::StreamPlanRef> {\n        use super::{StreamEowcSort, StreamFilter, StreamMatchRecognize};\n        use crate::error::ErrorCode;\n        use crate::expr::{ExprType, FunctionCall, InputRef};\n        use crate::optimizer::property::RequiredDist;\n        use crate::utils::Condition;\n        // v1 restrictions: PARTITION BY / ORDER BY must be plain columns, PARTITION BY non-empty.\n        // `NotSupported(cause, hint)` throughout, matching this feature's binder-side validation.\n        if self.core.partition_key_indices().is_none() || self.core.order_key_indices().is_none() {\n            return Err(ErrorCode::NotSupported(\n                \"MATCH_RECOGNIZE with an expression in PARTITION BY or ORDER BY\".to_owned(),\n                \"use plain column references; compute the expression in a view below and \\\n                 partition/order by the resulting column\"\n                    .to_owned(),","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/logical_match_recognize.rs#L177-L213","documentation":"`LogicalMatchRecognize::to_batch` deliberately bails with `ErrorCode::NotSupported`: the `MATCH_RECOGNIZE` clause has no batch (query-time, non-materialized) execution path. It is only implemented for streaming plans (via `StreamMatchRecognize`), so any attempt to plan `MATCH_RECOGNIZE` as a batch query fails here.","triggerScenarios":"Running a `SELECT ... MATCH_RECOGNIZE ...` statement as a batch/ad-hoc query (not inside a `CREATE MATERIALIZED VIEW`), or any batch planning path (`to_batch`) that encounters a `LogicalMatchRecognize` node.","commonSituations":"Users try the standard SQL pattern `SELECT * FROM t MATCH_RECOGNIZE (...)` directly in psql; in RisingWave it only works when creating a materialized view or in a streaming context.","solutions":["Wrap the MATCH_RECOGNIZE query in `CREATE MATERIALIZED VIEW ... AS SELECT ... MATCH_RECOGNIZE ...` so it is planned for streaming instead of batch.","Query the created materialized view afterwards for the matched rows.","If batch execution is genuinely needed, implement a `BatchMatchRecognize` plan node or wait for upstream support; track the feature request."],"exampleFix":"// before: batch query fails\nSELECT * FROM ticker MATCH_RECOGNIZE (PARTITION BY symbol ORDER BY ts ...) ;\n// after: plan it as a stream\nCREATE MATERIALIZED VIEW matches AS\nSELECT * FROM ticker MATCH_RECOGNIZE (PARTITION BY symbol ORDER BY ts ...);\nSELECT * FROM matches;","handlingStrategy":"validation","validationCode":"-- guard: MATCH_RECOGNIZE only works in a streaming (materialized view) context\n-- avoid running it as an ad-hoc batch SELECT","typeGuard":null,"tryCatchPattern":"match client.query(\"SELECT * FROM t MATCH_RECOGNIZE (...)\") {\n    Err(e) if e.to_string().contains(\"BatchMatchRecognize is not implemented\") => {\n        eprintln!(\"Create a materialized view with MATCH_RECOGNIZE instead of a batch query\");\n    }\n    r => r?,\n}","preventionTips":["Always wrap MATCH_RECOGNIZE in CREATE MATERIALIZED VIEW; never run it as a one-off batch query.","Check RisingWave release notes for batch MATCH_RECOGNIZE support before using it in ad-hoc SQL.","Document this streaming-only limitation in team SQL style guides."],"tags":["sql","match-recognize","batch","unsupported-feature"],"backgroundTag":"unsupported-operation","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"}