{"record":{"id":"f26ebc3e8847c3f3","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-f26ebc","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/SpannerPostgreSQLSqlAstTranslator.java","lineNumber":60,"sourceCode":"\t\tregisterAffectedTable(tableReference);\n\t\t// ALWAYS render the alias for the target table since Spanner doesn't support\n\t\t// FROM in UPDATE\n\t\tfinal Clause currentClause = getClauseStack().getCurrent();\n\t\tif ( currentClause == Clause.UPDATE || currentClause == Clause.DELETE) {\n\t\t\trenderTableReferenceIdentificationVariable(tableReference);\n\t\t}\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\tprotected void renderLikePredicate(LikePredicate likePredicate) {\n\t\t// We need a custom implementation here because Spanner\n\t\t// uses the backslash character as default escape character\n\t\tif (likePredicate.getEscapeCharacter() == null) {\n\t\t\trenderBackslashEscapedLikePattern( likePredicate.getPattern(), likePredicate.getEscapeCharacter(), true );\n\t\t}\n\t\telse {\n\t\t\trenderLikePattern( likePredicate.getPattern(), likePredicate.getEscapeCharacter() );\n\t\t}\n\t}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/SpannerPostgreSQLSqlAstTranslator.java#L42-L78","documentation":"Cloud Spanner's PostgreSQL interface does not implement grouping sets / rollup / cube. SpannerPostgreSQLSqlAstTranslator.renderPartitionItem throws UnsupportedOperationException('Summarization is not supported by DBMS') when a Summarization expression (rollup/cube/grouping sets from HQL GROUP BY or window PARTITION BY items) has to be rendered. The code comment notes the only emulation -- rendering every grouping variation connected by union all at the query-spec level -- is not implemented.","triggerScenarios":"Running HQL like 'group by rollup(a,b)', 'group by cube(a,b)' or 'group by grouping sets ((a),(b),())' (or an OVER (PARTITION BY rollup(...)) item) against a SessionFactory configured with SpannerPostgreSQLDialect. Throws during SQL rendering, before execution on Spanner.","commonSituations":"Moving an analytics/reporting workload from PostgreSQL to Cloud Spanner (PG interface) and keeping the rollup queries; running the same test suite against Spanner PostgreSQL that was written for vanilla PostgreSQL.","solutions":["Rewrite the report as one plain GROUP BY query per grouping level and merge the result sets (union all semantics) in application code","Compute totals/subtotals in separate aggregate queries and stitch them together in Java","Export the data to BigQuery (or run against real PostgreSQL) for grouping-sets-heavy reporting instead of Spanner","Pre-materialize the grouped levels into a table via several Spanner queries, then query that table"],"exampleFix":"// before (throws on Spanner PostgreSQL)\n\"select region, product, sum(amount) from Sale s group by rollup (s.region, s.product)\"\n\n// after: per-level queries merged in memory\nperRegionProduct = em.createQuery(\"select region, product, sum(amount) ... group by region, product\");\nperRegion        = em.createQuery(\"select region, sum(amount) ... group by region\");\ngrandTotal       = em.createQuery(\"select sum(amount) from Sale s\");","handlingStrategy":"validation","validationCode":"static boolean supportsSummarization(Dialect dialect) {\n    return !(dialect instanceof SpannerPostgreSQLDialect || dialect instanceof SpannerDialect\n        || dialect instanceof HSQLDialect || dialect instanceof SybaseASEDialect);\n}\n\nif (queryUsesRollup(hql) && !supportsSummarization(dialect)) {\n    return analyticsService.expandedGrouping(query); // per-level queries merged in app\n}","typeGuard":null,"tryCatchPattern":"try {\n    return em.createQuery(rollupHql, Object[].class).getResultList();\n} catch (UnsupportedOperationException e) {\n    if (\"Summarization is not supported by DBMS\".equals(e.getMessage())) {\n        return analyticsService.expandedGrouping(query);\n    }\n    throw e;\n}","preventionTips":["Treat 'works on PostgreSQL' as proof of nothing for Spanner PG -- verify OLAP syntax against Spanner docs","Keep reporting queries behind an interface with per-dialect implementations","Add a Spanner-PG profile to the integration test matrix for analytics queries"],"tags":["hibernate","cloud-spanner","postgresql","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"}