{"record":{"id":"c04fb2c6bd7520ee","repo":"cube-js/cube","slug":"prevreferencedpreaggregation-cube-prevrefere","errorCode":null,"errorMessage":"'${prevReferencedPreAggregation.cube}.${prevReferencedPreAggregation.preAggregationName}' and '${referencedPreAggregation.cube}.${referencedPreAggregation.preAggregationName}' referenced by '${cube}.${preAggregationName}' rollupLambda have incompatible partition granularities. '${partitionGranularityPrev}' can't be padded by '${partitionGranularity}'","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' referenced by '(.+?)\\.(.+?)' rollupLambda have incompatible partition granularities\\. '(.+?)' can't be padded by '(.+?)'","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts","lineNumber":1231,"sourceCode":"          throw new UserError(`unionWithSourceData can be enabled only for pre-aggregation within '${preAggObj.cube}' cube but '${referencedPreAggregations[i].preAggregationName}' pre-aggregation is defined within '${referencedPreAggregations[i].cube}' cube`);\n        }\n        referencedPreAggregations[i] = {\n          ...referencedPreAggregations[i],\n          preAggregation: {\n            ...referencedPreAggregations[i].preAggregation,\n            unionWithSourceData: i === referencedPreAggregations.length - 1 ? preAggObj.preAggregation.unionWithSourceData : false,\n            rollupLambdaId: `${cube}.${preAggregationName}`,\n            lastRollupLambda: i === referencedPreAggregations.length - 1,\n            rollupLambdaTimeDimensionsReference: preAggObj.references.timeDimensions,\n          }\n        };\n        if (i > 0) {\n          const partitionGranularity = PreAggregations.checkPartitionGranularityDefined(cube, preAggregationName, referencedPreAggregations[i]);\n          const prevReferencedPreAggregation = referencedPreAggregations[i - 1];\n          const partitionGranularityPrev = PreAggregations.checkPartitionGranularityDefined(cube, preAggregationName, prevReferencedPreAggregation);\n          const minGranularity = this.query.minGranularity(partitionGranularityPrev, partitionGranularity);\n          if (minGranularity !== partitionGranularity) {\n            throw new UserError(`'${prevReferencedPreAggregation.cube}.${prevReferencedPreAggregation.preAggregationName}' and '${referencedPreAggregation.cube}.${referencedPreAggregation.preAggregationName}' referenced by '${cube}.${preAggregationName}' rollupLambda have incompatible partition granularities. '${partitionGranularityPrev}' can't be padded by '${partitionGranularity}'`);\n          }\n        }\n        PreAggregations.memberNameMismatchValidation(preAggObj, referencedPreAggregation, 'measures');\n        PreAggregations.memberNameMismatchValidation(preAggObj, referencedPreAggregation, 'dimensions');\n        PreAggregations.memberNameMismatchValidation(preAggObj, referencedPreAggregation, 'timeDimensions');\n      });\n      referencedPreAggregations.forEach(preAgg => {\n        references.rollupsReferences.push(preAgg.references);\n      });\n      const lambdaResult = canUsePreAggregation(references);\n      return {\n        ...preAggObj,\n        canUsePreAggregation: lambdaResult.canUse,\n        leafMeasureMatch: lambdaResult.leafMeasureMatch,\n        referencedPreAggregations,\n      };\n    } else {\n      return preAggObj;","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts#L1213-L1249","documentation":"A rollupLambda concatenates multiple partitioned rollups; consecutive rollups' partition granularities must be compatible such that the finer one can be padded to the coarser one (minGranularity must equal the second granularity). When 'partitionGranularityPrev' cannot be padded by 'partitionGranularity', this UserError is thrown.","triggerScenarios":"In buildRollupLambdaPreAggregations, for i > 0, minGranularity(prev, current) !== current — e.g. chaining a rollup partitioned by 'month' after one partitioned by 'day' in an incompatible order for the lambda's concatenation.","commonSituations":"Mixing day-partitioned and month-partitioned rollups in one lambda; adding a new rollup to a lambda with a different partitionGranularity; copying a lambda across cubes where partitionGranularity differs.","solutions":["Align partitionGranularity across all rollups referenced by the lambda (e.g. all 'month').","Reorder the rollups array so granularities are pad-compatible.","Split incompatible rollups into separate lambdas."],"exampleFix":"// before\nrollups: [CUBE.ordersByDay /* partitionGranularity: day */, CUBE.ordersByMonth /* month */]\n// after\nrollups: [CUBE.ordersByDay, CUBE.ordersByWeek, CUBE.ordersByMonth] // or align both to 'month'","handlingStrategy":"validation","validationCode":"// Check consecutive partition granularities are pad-compatible before defining the lambda\nconst ORDER = { day: 1, week: 2, month: 3, quarter: 4, year: 5 };\nfunction padCompatible(prev, cur) { return ORDER[cur] >= ORDER[prev]; }\nconst grans = rollups.map(r => r.partitionGranularity);\ngrans.every((g, i) => i === 0 || padCompatible(grans[i - 1], g)) || (() => { throw new Error('Incompatible partitionGranularity sequence in rollupLambda'); })();","typeGuard":"null","tryCatchPattern":"try { await cube.query(query); } catch (e) { if (/have incompatible partition granularities/.test(e.message)) { console.error('Align partitionGranularity or reorder rollups:', e.message); } else throw e; }","preventionTips":["Standardize one partitionGranularity (e.g. month) across a lambda's rollups","Order rollups from finest to coarsest granularity","Update all rollups' partitionGranularity together when changing one","Add schema tests that iterate rollupLambdas and compare granularities"],"tags":["pre-aggregation","rollup-lambda","partition-granularity","compatibility"],"backgroundTag":"incompatible-partition-granularity","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}