hibernate/hibernate-orm · error · UnsupportedOperationException

Summarization is not supported by DBMS

Error message

Summarization is not supported by DBMS

What it means

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).

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/SpannerSqlAstTranslator.java:140

			ComparisonOperator operator) {
		emulateSelectTupleComparison( lhsExpressions, tuple.getExpressions(), operator, true );
	}

	@Override
	protected void renderFetchFirstRow() {
		appendSql( " limit 1" );
	}

	@Override
	protected void renderPartitionItem(Expression expression) {
		if ( expression instanceof Literal ) {
			appendSql( "'0' || '0'" );
		}
		else if ( expression instanceof Summarization ) {
			// This could theoretically be emulated by rendering all grouping variations of the query and
			// connect them via union all but that's probably pretty inefficient and would have to happen
			// on the query spec level
			throw new UnsupportedOperationException( "Summarization is not supported by DBMS" );
		}
		else {
			expression.accept( this );
		}
	}

	@Override
	public void visitSelectClause(SelectClause selectClause) {
		getClauseStack().push( Clause.SELECT );

		try {
			appendSql( "select " );
			if ( correlated ) {
				appendSql( "as struct " );
			}
			if ( selectClause.isDistinct() ) {
				appendSql( "distinct " );
			}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Split into one plain GROUP BY query per grouping level and union/merge client-side
  2. Replace rollup totals with separate total queries combined in application code
  3. Move grouping-sets analytics off Spanner (BigQuery / warehouse) and keep only simple aggregates on Spanner
  4. Precompute the grouping levels into a summary table maintained by your application

Example fix

// before (throws on Spanner)
"select dept, seniority, avg(salary) from Employee e group by rollup (e.dept, e.seniority)"

// after
departments = em.createQuery("select dept, avg(salary) ... group by dept");
overall     = em.createQuery("select avg(salary) from Employee e");
Defensive patterns

Strategy: validation

Validate before calling

static boolean supportsSummarization(Dialect dialect) {
    return !(dialect instanceof SpannerDialect || dialect instanceof SpannerPostgreSQLDialect
        || dialect instanceof HSQLDialect || dialect instanceof SQLAnywhereDialect);
}

if (!supportsSummarization(dialect)) {
    // render one plain GROUP BY per level and merge client-side
}

Try / catch

try {
    return em.createQuery(groupingSetsHql, Object[].class).getResultList();
} catch (UnsupportedOperationException e) {
    if ("Summarization is not supported by DBMS".equals(e.getMessage())) {
        return reportFallback.perLevelGrouping(baseQuery);
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/32df936d8b60b43d. Report an issue: GitHub.