{"record":{"id":"047f3806810065b1","repo":"cube-js/cube","slug":"output-schema-is-only-supported-for-rollup-pre-agg","errorCode":null,"errorMessage":"Output schema is only supported for rollup pre-aggregations","messagePattern":"Output schema is only supported for rollup pre-aggregations","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseQuery.js","lineNumber":4525,"sourceCode":"            return {\n              name: this.aliasName(member),\n              type: outputSchemaType.type,\n            };\n          };\n\n          // The order of the output columns is important, it should match the order in the select statement\n          const outputColumnTypes = [\n            ...(query.dimensions || []).map(d => findSchemaType(d.dimension)),\n            ...(query.timeDimensions || []).map(t => ({\n              name: `${this.aliasName(t.dimension)}_${t.granularity}`,\n              type: 'TIMESTAMP'\n            })),\n            ...(query.measures || []).map(m => findSchemaType(m.measure)),\n          ];\n\n          return outputColumnTypes;\n        }\n        throw new UserError('Output schema is only supported for rollup pre-aggregations');\n      },\n      { inputProps: {}, cache: this.queryCache }\n    );\n  }\n\n  preAggregationUniqueKeyColumns(cube, preAggregation) {\n    if (preAggregation.uniqueKeyColumns) {\n      return preAggregation.uniqueKeyColumns.map(key => this.aliasName(`${cube}.${key}`));\n    }\n\n    return this.dimensionColumns();\n  }\n\n  preAggregationReadOnly(_cube, _preAggregation) {\n    return false;\n  }\n\n  preAggregationAllowUngroupingWithPrimaryKey(_cube, _preAggregation) {","sourceCodeStart":4507,"sourceCodeEnd":4543,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js#L4507-L4543","documentation":"Output schema (explicit output column typing via outputColumnTypes/output columns mapping) is implemented only for 'rollup' type pre-aggregations. BaseQuery.preAggregationOutputColumnTypes throws this UserError when output schema is requested for any other pre-aggregation type (e.g. originalSql or rollupLambda).","triggerScenarios":"Declaring an output columns schema on a pre-aggregation whose type is not 'rollup', or having the compiler evaluate output column types for an originalSql/rollupLambda pre-aggregation that inherited such config.","commonSituations":"Copying an outputColumns config from a rollup pre-aggregation to an originalSql pre-aggregation; a shared pre-aggregation factory that attaches outputColumns regardless of type; migration tooling generating output schema for all pre-aggregations.","solutions":["Move the output schema declaration to a rollup-type pre-aggregation","Remove the outputColumns/output schema config from the non-rollup pre-aggregation","If column typing is needed for originalSql, cast types in the underlying SQL instead"],"exampleFix":"// before\npreAggregations: {\n  source: {\n    type: 'originalSql',\n    outputColumnTypes: { 'orders.count': 'bigint' }\n  }\n}\n// after\npreAggregations: {\n  main: {\n    type: 'rollup',\n    measureReferences: [orders.count],\n    outputColumnTypes: { 'orders.count': 'bigint' }\n  }\n}","handlingStrategy":"validation","validationCode":"if (pa.outputColumnTypes && pa.type !== 'rollup') throw new Error('outputColumnTypes requires type: rollup');","typeGuard":"const supportsOutputSchema = (pa) => pa?.type === 'rollup' && pa.outputColumnTypes != null;","tryCatchPattern":"try { await cubeApi.query(q); } catch (e) { if (e.message === 'Output schema is only supported for rollup pre-aggregations') { /* strip outputColumnTypes from non-rollup pre-aggs */ } throw e; }","preventionTips":["Only attach outputColumnTypes to type: 'rollup' pre-aggregations","Centralize pre-aggregation factories so output schema is applied conditionally","Review auto-generated pre-aggregation configs for type/output mismatches"],"tags":["pre-aggregation","output-schema","unsupported-feature"],"backgroundTag":"unsupported-pre-aggregation-feature","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}