Skip to content

Commit ce7420c

Browse files
committed
fix incorrect cache for pre-aggs
1 parent 6f1e3ae commit ce7420c

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
@@ -1414,7 +1414,15 @@ export class PreAggregations {
14141414
if (!preAggregationName) {
14151415
return evaluateReferences();
14161416
}
1417-
return this.query.cacheValue(['evaluateAllReferences', cube, preAggregationName], evaluateReferences);
1417+
1418+
// Using [cube, preAggregationName] alone as cache keys isn’t reliable,
1419+
// as different queries can build distinct join graphs during pre-aggregation matching.
1420+
// Because the matching logic compares join subgraphs — particularly for 'rollupJoin' and 'rollupLambda'
1421+
// pre-aggregations — relying on such keys may cause incorrect results.
1422+
return this.query.cacheValue(
1423+
['evaluateAllReferences', cube, preAggregationName, JSON.stringify(this.query.join)],
1424+
evaluateReferences
1425+
);
14181426
}
14191427

14201428
public originalSqlPreAggregationTable(preAggregationDescription: PreAggregationForCube): string {

0 commit comments

Comments
 (0)