{"record":{"id":"134a341f763f99d4","repo":"cube-js/cube","slug":"this-query-doesnt-have-a-plan-because-it-already","errorCode":null,"errorMessage":"This query doesnt have a plan, because it already has values for response","messagePattern":"This query doesnt have a plan, because it already has values for response","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cubesql/cubesql/src/compile/plan.rs","lineNumber":141,"sourceCode":"\n    pub fn as_logical_plan(&self) -> LogicalPlan {\n        self.try_as_logical_plan().cloned().unwrap()\n    }\n\n    pub async fn as_physical_plan(&self) -> Result<Arc<dyn ExecutionPlan>, CubeError> {\n        match self {\n            QueryPlan::DataFusionSelect(plan, ctx)\n            | QueryPlan::CreateTempTable(plan, ctx, _, _, _) => {\n                DataFrame::new(ctx.state.clone(), plan)\n                    .create_physical_plan()\n                    .await\n                    .map_err(|e| CubeError::from(e))\n            }\n            QueryPlan::MetaOk(_, _)\n            | QueryPlan::MetaTabular(_, _)\n            | QueryPlan::CopyFrom(_)\n            | QueryPlan::CreateEmptyTempTable(_) => {\n                panic!(\"This query doesnt have a plan, because it already has values for response\")\n            }\n        }\n    }\n\n    pub fn print(&self, pretty: bool) -> Result<String, CubeError> {\n        match self {\n            QueryPlan::DataFusionSelect(plan, _) | QueryPlan::CreateTempTable(plan, _, _, _, _) => {\n                if pretty {\n                    Ok(plan.display_indent().to_string())\n                } else {\n                    Ok(plan.display().to_string())\n                }\n            }\n            QueryPlan::MetaOk(_, _)\n            | QueryPlan::MetaTabular(_, _)\n            | QueryPlan::CopyFrom(_)\n            | QueryPlan::CreateEmptyTempTable(_) => Ok(\n                \"This query doesnt have a plan, because it already has values for response\"","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubesql/cubesql/src/compile/plan.rs#L123-L159","documentation":"CubeSQL's as_physical_plan() panics when the QueryPlan is a terminal/meta variant (MetaOk, MetaTabular, CopyFrom, CreateEmptyTempTable). These plans carry their response values directly and never produce a physical execution plan.","triggerScenarios":"Calling as_physical_plan() on a QueryPlan that already holds final response values (meta queries, COPY FROM, create-empty-temp-table) instead of a real query plan.","commonSituations":"Planner bugs where a meta-response plan reaches the physical planning stage; custom SQL proxy code misinterpreting plan variants; queries like COPY FROM routed through the normal plan path.","solutions":["Check the QueryPlan variant before calling as_physical_plan and handle MetaOk/MetaTabular/CopyFrom/CreateEmptyTempTable by extracting their values directly.","Route meta queries through the response-returning path instead of physical planning.","File/inspect upstream: this panic usually indicates a planner routing bug in cubesql."],"exampleFix":"// before\nlet physical = plan.as_physical_plan()?;\n// after\nlet physical = match plan {\n    QueryPlan::MetaOk(..) | QueryPlan::MetaTabular(..) => return Ok(plan_response(plan)),\n    _ => plan.as_physical_plan()?,\n};","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_plan_executable(plan: &QueryPlan) -> bool {\n    !matches!(plan,\n        QueryPlan::MetaOk(_, _)\n        | QueryPlan::MetaTabular(_, _)\n        | QueryPlan::CopyFrom(_)\n        | QueryPlan::CreateEmptyTempTable(_))\n}","tryCatchPattern":"// panic!, not Result — cannot catch in Rust; guard before calling\nif is_plan_executable(&plan) {\n    let physical = plan.as_physical_plan()?;\n} else {\n    return handle_meta_response(plan);\n}","preventionTips":["Handle meta/copy plans on their dedicated response path","Add variant checks before physical planning","Cover meta query routing with tests"],"tags":["rust","cubesql","panic","planner"],"backgroundTag":"unsupported-plan-type","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}