{"record":{"id":"36d2ffe35e05b606","repo":"cube-js/cube","slug":"unknown-pre-aggregation-type-preaggregation-typ","errorCode":null,"errorMessage":"Unknown pre-aggregation type '${preAggregation.type}' in '${cube}'","messagePattern":"Unknown pre-aggregation type '(.+?)' in '(.+?)'","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseQuery.js","lineNumber":4479,"sourceCode":"            collectOriginalSqlPreAggregations\n          });\n        } else if (preAggregation.type === 'originalSql') {\n          const originalSqlPreAggregationQuery = this.preAggregations.originalSqlPreAggregationQuery(\n            cube,\n            preAggregation\n          );\n          const cubeFromPath = this.cubeEvaluator.cubeFromPath(cube);\n          return this.paramAllocator.buildSqlAndParams(originalSqlPreAggregationQuery.evaluateSymbolSqlWithContext(\n            () => {\n              if (cubeFromPath.sqlTable) {\n                return `SELECT * FROM ${originalSqlPreAggregationQuery.cubeSql(cube)}`;\n              }\n              return originalSqlPreAggregationQuery.evaluateSql(cube, cubeFromPath.sql);\n            },\n            { preAggregationQuery: true, collectOriginalSqlPreAggregations }\n          ));\n        }\n        throw new UserError(`Unknown pre-aggregation type '${preAggregation.type}' in '${cube}'`);\n      },\n      { inputProps: { collectOriginalSqlPreAggregations: [] }, cache: this.queryCache }\n    );\n  }\n\n  preAggregationOutputColumnTypes(cube, preAggregation) {\n    return this.cacheValue(\n      ['preAggregationOutputColumnTypes', cube, JSON.stringify(preAggregation)],\n      () => {\n        if (!preAggregation.outputColumnTypes) {\n          return null;\n        }\n\n        if (preAggregation.type === 'rollup') {\n          const query = this.preAggregations.rollupPreAggregationQuery(cube, preAggregation);\n\n          const evaluatedMapOutputColumnTypes = preAggregation.outputColumnTypes.reduce((acc, outputColumnType) => {\n            acc.set(outputColumnType.name, outputColumnType);","sourceCodeStart":4461,"sourceCodeEnd":4497,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js#L4461-L4497","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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"],"exampleFix":"// before\npreAggregations: {\n  main: {\n    type: 'rollups',\n    measureReferences: [orders.count]\n  }\n}\n// after\npreAggregations: {\n  main: {\n    type: 'rollup',\n    measureReferences: [orders.count]\n  }\n}","handlingStrategy":"validation","validationCode":"const VALID = ['rollup', 'rollupLambda', 'originalSql'];\nfor (const [name, pa] of Object.entries(cube.preAggregations || {})) {\n  if (!VALID.includes(pa.type)) throw new Error(`Pre-aggregation '${name}' has invalid type: ${pa.type}`);\n}","typeGuard":"const isKnownPreAggType = (t) => typeof t === 'string' && ['rollup','rollupLambda','originalSql'].includes(t);","tryCatchPattern":"try { await cubeApi.query(query); } catch (e) { if (String(e.message).includes('Unknown pre-aggregation type')) { /* fix model type field */ } throw e; }","preventionTips":["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"],"tags":["pre-aggregation","schema-compiler","user-error"],"backgroundTag":"invalid-pre-aggregation-type","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}