{"record":{"id":"04393768e5bd9d3b","repo":"cube-js/cube","slug":"unsupported-grouping-set-type","errorCode":null,"errorMessage":"Unsupported grouping set type: {:?}","messagePattern":"Unsupported grouping set type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cubesql/cubesql/src/compile/rewrite/converter.rs","lineNumber":572,"sourceCode":"                        flat_list\n                    );\n                    let expr_type =\n                        add_expr_data_node!(graph, GroupingSetType::Rollup, GroupingSetExprType);\n                    graph.add(LogicalPlanLanguage::GroupingSetExpr([members, expr_type]))\n                }\n                GroupingSet::Cube(members) => {\n                    let members = add_binary_expr_list_node!(\n                        graph,\n                        members,\n                        query_params,\n                        GroupingSetExprMembers,\n                        false\n                    );\n                    let expr_type =\n                        add_expr_data_node!(graph, GroupingSetType::Cube, GroupingSetExprType);\n                    graph.add(LogicalPlanLanguage::GroupingSetExpr([members, expr_type]))\n                }\n                _ => unimplemented!(\"Unsupported grouping set type: {:?}\", expr),\n            },\n            // TODO: Support all\n            _ => unimplemented!(\"Unsupported node type: {:?}\", expr),\n        })\n    }\n\n    pub fn add_logical_plan(&mut self, plan: &LogicalPlan) -> Result<Id, CubeError> {\n        self.add_logical_plan_replace_params(\n            plan,\n            &mut None,\n            &LogicalPlanToLanguageContext::default(),\n        )\n    }\n\n    pub fn add_logical_plan_replace_params(\n        &mut self,\n        plan: &LogicalPlan,\n        query_params: &mut Option<HashMap<usize, ScalarValue>>,","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubesql/cubesql/src/compile/rewrite/converter.rs#L554-L590","documentation":"During conversion of a DataFusion logical plan into the e-graph used by the CubeSQL rewriter, add_expr_replace_params matches known GroupingSet variants; any other grouping set type reaches unimplemented!(\"Unsupported grouping set type: {:?}\") and panics. CubeSQL only supports the specific grouping set shapes it converts (e.g. Rollup and Cube); other DataFusion grouping sets abort compilation.","triggerScenarios":"Running a query through the CubeSQL converter path with a GROUPING SETS / ROLLUP / CUBE expression whose variant is not the supported Rollup or Cube case, e.g. a compound GROUPING SETS list or combined GROUP BY with grouping sets in a position expression.","commonSituations":"Porting OLAP SQL with multi-dimensional rollups to Cube's SQL API; ORMs or BI tools generating GROUPING SETS; queries combining GROUPING SETS with parameter replacement.","solutions":["Rewrite the query to use plain GROUP BY with explicit rollups, or a single ROLLUP/CUBE form that the converter supports","Compute grouping sets client-side by issuing separate grouped queries and unioning results","Add support for the missing GroupingSet variant in add_expr_replace_params in rust/cubesql/cubesql/src/compile/rewrite/converter.rs","If on the legacy planner, try the Tesseract planner (CUBEJS_TESSERACT_SQL_PLANNER=true) which handles grouping sets differently"],"exampleFix":"// before\n-- fails in CubeSQL\nSELECT region, city, SUM(amount) FROM t GROUP BY GROUPING SETS ((region), (region, city), ());\n// after\nSELECT region, city, SUM(amount) FROM t GROUP BY ROLLUP (region, city);\n-- or split into separate queries per grouping set","handlingStrategy":"validation","validationCode":"// Reject unsupported GROUPING SETS shapes before sending to Cube SQL API\nfunction assertGroupingSupported(sql) {\n  if (/GROUPING\\s+SETS/i.test(sql) && !/GROUP\\s+BY\\s+ROLLUP\\s*\\(|GROUP\\s+BY\\s+CUBE\\s*\\(/i.test(sql)) {\n    throw new Error('Only ROLLUP/CUBE grouping forms are supported; rewrite GROUPING SETS');\n  }\n}\nassertGroupingSupported(sql);","typeGuard":"function isSupportedGroupingClause(sql) {\n  return !/GROUPING\\s+SETS\\s*\\(/i.test(sql) // plain grouping sets lists unsupported\n      || /GROUP\\s+BY\\s+(ROLLUP|CUBE)\\s*\\(/i.test(sql);\n}","tryCatchPattern":"try {\n  return await connection.query(sql);\n} catch (e) {\n  if (/Unsupported grouping set type/i.test(String(e.message))) {\n    // issue one query per grouping set and union in the client\n    return unionAll(splitGroupingSets(sql).map(q => connection.query(q)));\n  }\n  throw e;\n}","preventionTips":["Express multi-level totals with ROLLUP/CUBE rather than explicit GROUPING SETS lists","Compute compound grouping sets as separate queries unioned client-side","Consider the Tesseract planner for richer grouping-set support","Test all grouping SQL used by BI tools against CubeSQL early"],"tags":["rust","cubesql","grouping-sets","unimplemented","query-rewrite"],"backgroundTag":"unsupported-plan-node","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}