{"record":{"id":"034ccfc1aa29540a","repo":"cube-js/cube","slug":"output-schema-type-for-member-not-found-in-pre","errorCode":null,"errorMessage":"Output schema type for ${member} not found in pre-aggregation ${preAggregation}","messagePattern":"Output schema type for (.+?) not found in pre-aggregation (.+?)","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseQuery.js","lineNumber":4504,"sourceCode":"    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);\n            return acc;\n          }, new Map());\n\n          const findSchemaType = member => {\n            const outputSchemaType = evaluatedMapOutputColumnTypes.get(member);\n            if (!outputSchemaType) {\n              throw new UserError(`Output schema type for ${member} not found in pre-aggregation ${preAggregation}`);\n            }\n\n            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","sourceCodeStart":4486,"sourceCodeEnd":4522,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js#L4486-L4522","documentation":"When a pre-aggregation declares an outputColumns/type mapping, BaseQuery evaluates the output column types and builds an output schema by looking up each member (dimension/measure/timeDimension) in the evaluated map. If a member referenced by the query has no corresponding output column type entry, this UserError is thrown — the pre-aggregation's outputColumns do not cover the queried members.","triggerScenarios":"Querying a measure/dimension that participates in a pre-aggregation with `outputColumnTypes`/output schema declared, but that member is missing from the pre-aggregation definition (or its outputColumns list), so the evaluated map has no entry for it.","commonSituations":"Adding a new measure to a query without updating the pre-aggregation that serves it; renaming a member in the cube but not in the pre-aggregation's references; outputColumns listing only a subset of the referenced members.","solutions":["Add the missing member to the pre-aggregation's references/outputColumns so its output column type can be evaluated","Align the query's members with those actually defined in the pre-aggregation","Rebuild/restart the schema compiler after editing the data model to clear stale cached evaluation"],"exampleFix":"// before\npreAggregations: {\n  main: {\n    measureReferences: [orders.count],\n    outputColumnTypes: { 'orders.count': 'bigint' }\n  }\n}\n// querying orders.totalAmount too\n// after\npreAggregations: {\n  main: {\n    measureReferences: [orders.count, orders.totalAmount],\n    outputColumnTypes: { 'orders.count': 'bigint', 'orders.totalAmount': 'decimal' }\n  }\n}","handlingStrategy":"validation","validationCode":"const referenced = [...(pa.measureReferences||[]), ...(pa.dimensionReferences||[]), ...(pa.timeDimensionReferences||[])];\nconst missing = queryMembers.filter(m => !referenced.includes(m));\nif ((pa.outputColumnTypes) && missing.length) throw new Error(`Members missing from outputColumnTypes: ${missing}`);","typeGuard":"const hasOutputTypeFor = (pa, member) => Boolean(pa?.outputColumnTypes && pa.outputColumnTypes[member]);","tryCatchPattern":"try { const res = await cubeApi.query(q); } catch (e) { if (/Output schema type for .* not found/.test(e.message)) console.error('Update pre-aggregation outputColumns to cover:', e.message); throw e; }","preventionTips":["Keep pre-aggregation references and outputColumns in sync with queried members","When adding a measure, update every pre-aggregation that serves it","Rename members via find-and-replace across pre-aggregation definitions"],"tags":["pre-aggregation","output-schema","schema-compiler"],"backgroundTag":"pre-aggregation-member-mismatch","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}