{"record":{"id":"27653e766c21e47c","repo":"cube-js/cube","slug":"error-27653e","errorCode":null,"errorMessage":"{:?}","messagePattern":"\\{:\\?\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cubestore/cubestore/src/queryplanner/serialized_plan.rs","lineNumber":1307,"sourceCode":"            node.node.as_any().downcast_ref::<RollingWindowAggregate>()\n        {\n            ExtensionNodeSerialized::RollingWindowAggregate(\n                rolling_window_aggregate.to_serialized()?,\n            )\n        } else if let Some(topk_aggregate) = node\n            .node\n            .as_any()\n            .downcast_ref::<ClusterAggregateTopKUpper>()\n        {\n            ExtensionNodeSerialized::ClusterAggregateTopKUpper(topk_aggregate.to_serialized()?)\n        } else if let Some(topk_aggregate) = node\n            .node\n            .as_any()\n            .downcast_ref::<ClusterAggregateTopKLower>()\n        {\n            ExtensionNodeSerialized::ClusterAggregateTopKLower(topk_aggregate.to_serialized()?)\n        } else {\n            todo!(\"{:?}\", node)\n        };\n        to_serialize\n            .serialize(&mut ser)\n            .map_err(|e| DataFusionError::Execution(format!(\"try_encode: {}\", e)))?;\n        buf.extend(ser.take_buffer());\n        Ok(())\n    }\n\n    fn try_decode_table_provider(\n        &self,\n        buf: &[u8],\n        _table_ref: &TableReference,\n        _schema: SchemaRef,\n        _ctx: &SessionContext,\n    ) -> datafusion::common::Result<Arc<dyn TableProvider>> {\n        use serde::Deserialize;\n        let r = flexbuffers::Reader::get_root(buf)\n            .map_err(|e| DataFusionError::Execution(format!(\"try_decode_table_provider: {}\", e)))?;","sourceCodeStart":1289,"sourceCodeEnd":1325,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cubestore/src/queryplanner/serialized_plan.rs#L1289-L1325","documentation":"CubeStore's try_encode serializes a DataFusion logical/physical plan node into an ExtensionNodeSerialized variant; when it encounters a node type not covered by the downcast match (e.g. an unhandled ClusterAggregate* or other Extension node), it reaches todo!(\"{:?}\", node) and panics, printing the offending node. This means the planner produced a plan the serialization layer does not know how to encode for distribution.","triggerScenarios":"Executing a distributed CubeStore query whose plan contains an extension node missing from the try_encode match (e.g. a new/unsupported ClusterAggregateTopK variant, TopK besides Lower, or another extension node added without updating serialization).","commonSituations":"Version skew between cubestore nodes or between cubesql and cubestore where one side emits a plan node the other can't serialize; newly added planner features used before serialization support landed; queries hitting TopK/aggregate fast paths with unusual orderings/limits.","solutions":["Upgrade all CubeStore/cubesql components to matching versions so plan node sets align","Inspect the panicking node printed by the panic and add a serialization arm for it in rust/cubestore/cubestore/src/queryplanner/serialized_plan.rs try_encode","Rewrite the query to avoid the unsupported construct (e.g. simplify ORDER BY/LIMIT aggregates so the TopK extension path is not taken)"],"exampleFix":"// before\n} else {\n    todo!(\"{:?}\", node)\n};\n// after\n} else if let Some(topk) = node.as_any().downcast_ref::<ClusterAggregateTopKUpper>() {\n    ExtensionNodeSerialized::ClusterAggregateTopKUpper(topk.to_serialized()?)\n} else {\n    return Err(DataFusionError::Internal(format!(\n        \"try_encode: unsupported plan node {:?}\", node\n    )));\n};","handlingStrategy":"retry","validationCode":"// Ensure planner components are version-aligned before running distributed queries\nif (cubesqlVersion.major !== cubestoreVersion.major || cubesqlVersion.minor !== cubestoreVersion.minor) {\n  throw new Error('cubesql/cubestore version mismatch: upgrade all nodes together to avoid unsupported plan node serialization');\n}","typeGuard":"// Server-side guard before reaching the todo!\nfn can_encode(node: &Arc<dyn PhysicalPlan>) -> bool {\n    node.as_any().downcast_ref::<ClusterAggregateTopKLower>().is_some()\n        || node.as_any().downcast_ref::<ClusterAggregateTopKUpper>().is_some() // ...list all supported nodes\n}","tryCatchPattern":"// Client: catch the distributed-query failure and fall back to a simpler query\nlet result = match cluster.query(&sql).await {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"not implemented\") || e.to_string().contains(\"panic\") => {\n        cluster.query(&simplify_query(&sql)).await? // e.g. drop exotic ORDER BY/LIMIT aggregates\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Keep cubestore and cubesql on identical versions (upgrade together)","After adding a new extension plan node, add its serialization arm in serialized_plan.rs and a round-trip test","Avoid unusual ORDER BY + LIMIT aggregates that trigger TopK extension paths unless supported","Watch for panic logs mentioning serialized_plan.rs and report the printed node upstream"],"tags":["rust","cubestore","plan-serialization","todo-panic","distributed-query"],"backgroundTag":"unsupported-plan-node","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}