{"record":{"id":"00ccb825900f8744","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-00ccb8","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-community-dialects/src/main/java/org/hibernate/community/dialect/TeradataSqlAstTranslator.java","lineNumber":120,"sourceCode":"\n\t@Override\n\tprotected void renderSelectTupleComparison(\n\t\t\tList<SqlSelection> lhsExpressions,\n\t\t\tSqlTuple tuple,\n\t\t\tComparisonOperator operator) {\n\t\temulateSelectTupleComparison( lhsExpressions, tuple.getExpressions(), operator, true );\n\t}\n\n\t@Override\n\tprotected void renderPartitionItem(Expression expression) {\n\t\tif ( expression instanceof Literal ) {\n\t\t\tappendSql( \"()\" );\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}\n","sourceCodeStart":102,"sourceCodeEnd":128,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TeradataSqlAstTranslator.java#L102-L128","documentation":"Teradata has no native support for the Summarization AST node that represents ROLLUP/CUBE/GROUPING SETS inside GROUP BY. The translator's renderPartitionItem throws UnsupportedOperationException because the UNION ALL emulation over all grouping variations is not implemented for this dialect.","triggerScenarios":"HQL `group by rollup(...)`, `group by cube(...)` or `group by grouping sets(...)` (or Criteria grouping-set queries) executed with TeradataDialect.","commonSituations":"Data-warehouse reports with subtotal rollups written for other databases and re-run on Teradata; BI-generated HQL that includes grouping sets.","solutions":["Expand rollup/cube/grouping sets into a UNION ALL of individual GROUP BY queries","Use plain GROUP BY and aggregate subtotals in the application","Run the report as native Teradata SQL","Use Teradata-specific aggregation (e.g. GROUPING via native QUALIFY-style queries) through a native statement"],"exampleFix":"// before\nselect e.region, e.product, sum(e.amount) from Sale e\n group by rollup(e.region, e.product)\n\n// after\nselect e.region, e.product, sum(e.amount) from Sale e group by e.region, e.product\nunion all\nselect e.region, null, sum(e.amount) from Sale e group by e.region\nunion all\nselect null, null, sum(e.amount) from Sale e","handlingStrategy":"fallback","validationCode":"static boolean dialectSupportsSummarization(Dialect d) {\n    return !(d instanceof TeradataDialect); // plus Sybase family and TimesTen\n}","typeGuard":null,"tryCatchPattern":"try {\n    return runGroupingSetsQuery(hql);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Summarization\")) {\n        return runUnionAllEquivalent(hql);\n    }\n    throw e;\n}","preventionTips":["Do not rely on grouping sets in portable HQL","Keep a UNION ALL expansion generator for subtotal reports","Validate analytical queries per warehouse backend in CI"],"tags":["hibernate","teradata","grouping-sets","rollup","cube"],"backgroundTag":"grouping-sets-not-supported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}