Skip to content

Commit 8eadc73

Browse files
committed
fix incorrect cache for pre-aggs
1 parent 4e5e122 commit 8eadc73

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,15 @@ export class PreAggregations {
13981398
if (!preAggregationName) {
13991399
return evaluateReferences();
14001400
}
1401-
return this.query.cacheValue(['evaluateAllReferences', cube, preAggregationName], evaluateReferences);
1401+
1402+
// Using [cube, preAggregationName] alone as cache keys isn’t reliable,
1403+
// as different queries can build distinct join graphs during pre-aggregation matching.
1404+
// Because the matching logic compares join subgraphs — particularly for 'rollupJoin' and 'rollupLambda'
1405+
// pre-aggregations — relying on such keys may cause incorrect results.
1406+
return this.query.cacheValue(
1407+
['evaluateAllReferences', cube, preAggregationName, JSON.stringify(this.query.join)],
1408+
evaluateReferences
1409+
);
14021410
}
14031411

14041412
public originalSqlPreAggregationTable(preAggregationDescription: PreAggregationForCube): string {

0 commit comments

Comments
 (0)