cube-js/cube · error · UserError
Unknown pre-aggregation type '${preAggregation.type}' in '${
Error message
Unknown pre-aggregation type '${preAggregation.type}' in '${cube}' What it means
Cube's schema compiler only supports a fixed set of pre-aggregation types (e.g. rollup, rollupLambda, originalSql). When compiling a pre-aggregation definition whose 'type' field is not one of the known types, BaseQuery.preAggregationSymbolsForUsedPreAggregations aborts with this UserError. It protects against misspelled or unsupported type declarations in the data model.
Source
Thrown at packages/cubejs-schema-compiler/src/adapter/BaseQuery.js:4479
collectOriginalSqlPreAggregations
});
} else if (preAggregation.type === 'originalSql') {
const originalSqlPreAggregationQuery = this.preAggregations.originalSqlPreAggregationQuery(
cube,
preAggregation
);
const cubeFromPath = this.cubeEvaluator.cubeFromPath(cube);
return this.paramAllocator.buildSqlAndParams(originalSqlPreAggregationQuery.evaluateSymbolSqlWithContext(
() => {
if (cubeFromPath.sqlTable) {
return `SELECT * FROM ${originalSqlPreAggregationQuery.cubeSql(cube)}`;
}
return originalSqlPreAggregationQuery.evaluateSql(cube, cubeFromPath.sql);
},
{ preAggregationQuery: true, collectOriginalSqlPreAggregations }
));
}
throw new UserError(`Unknown pre-aggregation type '${preAggregation.type}' in '${cube}'`);
},
{ inputProps: { collectOriginalSqlPreAggregations: [] }, cache: this.queryCache }
);
}
preAggregationOutputColumnTypes(cube, preAggregation) {
return this.cacheValue(
['preAggregationOutputColumnTypes', cube, JSON.stringify(preAggregation)],
() => {
if (!preAggregation.outputColumnTypes) {
return null;
}
if (preAggregation.type === 'rollup') {
const query = this.preAggregations.rollupPreAggregationQuery(cube, preAggregation);
const evaluatedMapOutputColumnTypes = preAggregation.outputColumnTypes.reduce((acc, outputColumnType) => {
acc.set(outputColumnType.name, outputColumnType);View on GitHub (pinned to 7d981676b3)
Solutions
- Fix the `type` field of the pre-aggregation to a supported value: 'rollup', 'originalSql', or 'rollupLambda'
- Log/print the resolved preAggregation object to confirm what type value actually reaches the compiler (it may come from a factory function)
- Check the Cube docs for your version — supported types have changed over time
Example fix
// before
preAggregations: {
main: {
type: 'rollups',
measureReferences: [orders.count]
}
}
// after
preAggregations: {
main: {
type: 'rollup',
measureReferences: [orders.count]
}
} Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['rollup', 'rollupLambda', 'originalSql'];
for (const [name, pa] of Object.entries(cube.preAggregations || {})) {
if (!VALID.includes(pa.type)) throw new Error(`Pre-aggregation '${name}' has invalid type: ${pa.type}`);
} Type guard
const isKnownPreAggType = (t) => typeof t === 'string' && ['rollup','rollupLambda','originalSql'].includes(t);
Try / catch
try { await cubeApi.query(query); } catch (e) { if (String(e.message).includes('Unknown pre-aggregation type')) { /* fix model type field */ } throw e; } Prevention
- Only use documented type values: rollup, originalSql, rollupLambda
- Lint your data models for the type field
- Copy pre-aggregation examples from the docs matching your Cube version
When it happens
Trigger: A cube defines a pre-aggregation with `type:` set to a misspelled or non-existent value (e.g. 'rollups', 'RollUp', 'originaSql') instead of 'rollup', 'originalSql', or 'rollupLambda'.
Common situations: Typo in the data model YAML/JS; copying an example from docs for an older Cube version whose type name changed; building the pre-aggregation programmatically and passing an invalid type variable.
Related errors
- Unsupported measure type replacement for ${sourceMeasure}: $
- Unsupported additional filters for measure ${sourceMeasure}
- Only fixed rolling windows are supported by Cube Store but g
- Index SQL support is not implemented
- Output schema type for ${member} not found in pre-aggregatio
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/36d2ffe35e05b606.
Report an issue: GitHub.