{"record":{"id":"07368301bc2f26b3","repo":"risingwavelabs/risingwave","slug":"unimplemented-073683","errorCode":null,"errorMessage":"unimplemented","messagePattern":"unimplemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/logical_intersect.rs","lineNumber":100,"sourceCode":"\nimpl PredicatePushdown for LogicalIntersect {\n    fn predicate_pushdown(\n        &self,\n        predicate: Condition,\n        ctx: &mut PredicatePushdownContext,\n    ) -> PlanRef {\n        let new_inputs = self\n            .inputs()\n            .iter()\n            .map(|input| input.predicate_pushdown(predicate.clone(), ctx))\n            .collect_vec();\n        self.clone_with_inputs(&new_inputs)\n    }\n}\n\nimpl ToBatch for LogicalIntersect {\n    fn to_batch(&self) -> Result<crate::optimizer::plan_node::BatchPlanRef> {\n        unimplemented!()\n    }\n}\n\nimpl ToStream for LogicalIntersect {\n    fn to_stream(\n        &self,\n        _ctx: &mut ToStreamContext,\n    ) -> Result<crate::optimizer::plan_node::StreamPlanRef> {\n        unimplemented!()\n    }\n\n    fn logical_rewrite_for_stream(\n        &self,\n        _ctx: &mut RewriteStreamContext,\n    ) -> Result<(PlanRef, ColIndexMapping)> {\n        unimplemented!()\n    }\n}","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/logical_intersect.rs#L82-L118","documentation":"LogicalIntersect (SQL INTERSECT) does not implement a direct-to-batch conversion: its to_batch method calls unimplemented!(), which panics. INTERSECT must first be rewritten into equivalent EXCEPT/semijoin (or union-of-except) forms by an earlier logical rewrite rule; reaching to_batch on the raw node means that rewrite never happened.","triggerScenarios":"The batch conversion pass (to_batch) is invoked on a LogicalIntersect node that was not rewritten into EXCEPT form first — e.g. a planner regression or a code path that skips the intersect-to-except rewrite.","commonSituations":"Running INTERSECT queries after changes to the logical rewrite rules; bugs where the rewrite from INTERSECT to EXCEPT/set-operations is skipped; interacting with optimizer internals in development.","solutions":["Upgrade RisingWave: in released versions, INTERSECT queries are rewritten to EXCEPT before batch planning, so this panic indicates an optimizer bug worth reporting.","Simplify or rewrite the query using EXCEPT or equivalent joins if you hit this on a patched/dev build.","As a developer, ensure the rewrite rule converting LogicalIntersect to EXCEPT runs before to_batch, or implement to_batch properly."],"exampleFix":"// before\nimpl ToBatch for LogicalIntersect {\n    fn to_batch(&self) -> Result<BatchPlanRef> {\n        unimplemented!()\n    }\n}\n// after\nimpl ToBatch for LogicalIntersect {\n    fn to_batch(&self) -> Result<BatchPlanRef> {\n        bail!(\"LogicalIntersect should be rewritten to LogicalExcept before to_batch\")\n    }\n}","handlingStrategy":"try-catch","validationCode":"// For dev tooling: ensure INTERSECT queries are rewritten before batch conversion\nif plan_contains_intersect(batch_plan) {\n    return Err(\"apply intersect-to-except rewrite first\".into());\n}","typeGuard":"fn contains_intersect(plan: &PlanRef) -> bool {\n    plan.walk().any(|n| matches!(n.as_logical(), Some(LogicalNode::Intersect(_))))\n}","tryCatchPattern":"let r = std::panic::catch_unwind(|| planner.to_batch(plan));\nmatch r {\n    Ok(v) => v?,\n    Err(_) => return Err(anyhow!(\"unimplemented to_batch on intersect; apply the rewrite rule or report a bug\")),\n}","preventionTips":["Report this panic with the SQL — released planners rewrite INTERSECT before to_batch.","Prefer EXCEPT/JOIN formulations on dev or patched builds.","Ensure the intersect rewrite rule is enabled in the optimizer pipeline.","Add tests asserting LogicalIntersect never survives to batch conversion."],"tags":["rust","query-optimizer","intersect","set-operations","panic"],"backgroundTag":"method-not-implemented","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"}