cube-js/cube · error
Unsupported grouping set type: {:?}
Error message
Unsupported grouping set type: {:?} What it means
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.
Source
Thrown at rust/cubesql/cubesql/src/compile/rewrite/converter.rs:572
flat_list
);
let expr_type =
add_expr_data_node!(graph, GroupingSetType::Rollup, GroupingSetExprType);
graph.add(LogicalPlanLanguage::GroupingSetExpr([members, expr_type]))
}
GroupingSet::Cube(members) => {
let members = add_binary_expr_list_node!(
graph,
members,
query_params,
GroupingSetExprMembers,
false
);
let expr_type =
add_expr_data_node!(graph, GroupingSetType::Cube, GroupingSetExprType);
graph.add(LogicalPlanLanguage::GroupingSetExpr([members, expr_type]))
}
_ => unimplemented!("Unsupported grouping set type: {:?}", expr),
},
// TODO: Support all
_ => unimplemented!("Unsupported node type: {:?}", expr),
})
}
pub fn add_logical_plan(&mut self, plan: &LogicalPlan) -> Result<Id, CubeError> {
self.add_logical_plan_replace_params(
plan,
&mut None,
&LogicalPlanToLanguageContext::default(),
)
}
pub fn add_logical_plan_replace_params(
&mut self,
plan: &LogicalPlan,
query_params: &mut Option<HashMap<usize, ScalarValue>>,View on GitHub (pinned to 7d981676b3)
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
Example fix
// before -- fails in CubeSQL SELECT region, city, SUM(amount) FROM t GROUP BY GROUPING SETS ((region), (region, city), ()); // after SELECT region, city, SUM(amount) FROM t GROUP BY ROLLUP (region, city); -- or split into separate queries per grouping set
Defensive patterns
Strategy: validation
Validate before calling
// Reject unsupported GROUPING SETS shapes before sending to Cube SQL API
function assertGroupingSupported(sql) {
if (/GROUPING\s+SETS/i.test(sql) && !/GROUP\s+BY\s+ROLLUP\s*\(|GROUP\s+BY\s+CUBE\s*\(/i.test(sql)) {
throw new Error('Only ROLLUP/CUBE grouping forms are supported; rewrite GROUPING SETS');
}
}
assertGroupingSupported(sql); Type guard
function isSupportedGroupingClause(sql) {
return !/GROUPING\s+SETS\s*\(/i.test(sql) // plain grouping sets lists unsupported
|| /GROUP\s+BY\s+(ROLLUP|CUBE)\s*\(/i.test(sql);
} Try / catch
try {
return await connection.query(sql);
} catch (e) {
if (/Unsupported grouping set type/i.test(String(e.message))) {
// issue one query per grouping set and union in the client
return unionAll(splitGroupingSets(sql).map(q => connection.query(q)));
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported node type: {:?}
- This query doesnt have a plan, because it already has values
- Should be rewritten with UtcTimestamp function
- CreateExternalTable is not supported
- Explain is not supported
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/04393768e5bd9d3b.
Report an issue: GitHub.