{"record":{"id":"32df936d8b60b43d","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-32df93","errorCode":null,"errorMessage":"Summarization is not supported by DBMS","messagePattern":"Summarization is not supported by DBMS","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/SpannerSqlAstTranslator.java","lineNumber":140,"sourceCode":"\t\t\tComparisonOperator operator) {\n\t\temulateSelectTupleComparison( lhsExpressions, tuple.getExpressions(), operator, true );\n\t}\n\n\t@Override\n\tprotected void renderFetchFirstRow() {\n\t\tappendSql( \" limit 1\" );\n\t}\n\n\t@Override\n\tprotected void renderPartitionItem(Expression expression) {\n\t\tif ( expression instanceof Literal ) {\n\t\t\tappendSql( \"'0' || '0'\" );\n\t\t}\n\t\telse if ( expression instanceof Summarization ) {\n\t\t\t// This could theoretically be emulated by rendering all grouping variations of the query and\n\t\t\t// connect them via union all but that's probably pretty inefficient and would have to happen\n\t\t\t// on the query spec level\n\t\t\tthrow new UnsupportedOperationException( \"Summarization is not supported by DBMS\" );\n\t\t}\n\t\telse {\n\t\t\texpression.accept( this );\n\t\t}\n\t}\n\n\t@Override\n\tpublic void visitSelectClause(SelectClause selectClause) {\n\t\tgetClauseStack().push( Clause.SELECT );\n\n\t\ttry {\n\t\t\tappendSql( \"select \" );\n\t\t\tif ( correlated ) {\n\t\t\t\tappendSql( \"as struct \" );\n\t\t\t}\n\t\t\tif ( selectClause.isDistinct() ) {\n\t\t\t\tappendSql( \"distinct \" );\n\t\t\t}","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/SpannerSqlAstTranslator.java#L122-L158","documentation":"Cloud Spanner (GoogleSQL dialect) has no support for SQL:2011 summarization. SpannerSqlAstTranslator.renderPartitionItem throws UnsupportedOperationException('Summarization is not supported by DBMS') when the HQL GROUP BY / window PARTITION BY item is a Summarization node (rollup, cube, grouping sets). Rendering literal partition items is handled ('0' || '0' trick), but summarization is deliberately unsupported since the union-all emulation is not implemented (see in-code comment).","triggerScenarios":"HQL with 'group by rollup(...)', 'group by cube(...)', 'group by grouping sets (...)' or an equivalent window PARTITION BY summarization, executed with SpannerDialect. Fails at SQL generation time -- nothing is sent to Spanner.","commonSituations":"Porting existing reporting HQL to a Spanner-backed deployment; integration tests for reports accidentally running against the Spanner profile; assuming GoogleSQL supports grouping sets because it supports some OLAP features.","solutions":["Split into one plain GROUP BY query per grouping level and union/merge client-side","Replace rollup totals with separate total queries combined in application code","Move grouping-sets analytics off Spanner (BigQuery / warehouse) and keep only simple aggregates on Spanner","Precompute the grouping levels into a summary table maintained by your application"],"exampleFix":"// before (throws on Spanner)\n\"select dept, seniority, avg(salary) from Employee e group by rollup (e.dept, e.seniority)\"\n\n// after\ndepartments = em.createQuery(\"select dept, avg(salary) ... group by dept\");\noverall     = em.createQuery(\"select avg(salary) from Employee e\");","handlingStrategy":"validation","validationCode":"static boolean supportsSummarization(Dialect dialect) {\n    return !(dialect instanceof SpannerDialect || dialect instanceof SpannerPostgreSQLDialect\n        || dialect instanceof HSQLDialect || dialect instanceof SQLAnywhereDialect);\n}\n\nif (!supportsSummarization(dialect)) {\n    // render one plain GROUP BY per level and merge client-side\n}","typeGuard":null,"tryCatchPattern":"try {\n    return em.createQuery(groupingSetsHql, Object[].class).getResultList();\n} catch (UnsupportedOperationException e) {\n    if (\"Summarization is not supported by DBMS\".equals(e.getMessage())) {\n        return reportFallback.perLevelGrouping(baseQuery);\n    }\n    throw e;\n}","preventionTips":["Assume no grouping sets on Spanner; design reports as per-level queries from the start","Gate rollup/cube usage behind a capability check helper reused across the codebase","Include Spanner in cross-dialect query tests when analytics HQL changes"],"tags":["hibernate","cloud-spanner","googlesql","hql","group-by","rollup","grouping-sets"],"backgroundTag":"grouping-sets-not-supported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}