Skip to content

Commit 7232a01

Browse files
committed
add joinTree evaluation for pre-agg
1 parent 767a71e commit 7232a01

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { CubeSymbols } from '../compiler/CubeSymbols';
44
import { UserError } from '../compiler/UserError';
55
import { BaseQuery } from './BaseQuery';
66
import {
7-
PreAggregationDefinition, PreAggregationDefinitions,
7+
PreAggregationDefinition,
8+
PreAggregationDefinitions,
89
PreAggregationReferences,
910
PreAggregationTimeDimensionReference
1011
} from '../compiler/CubeEvaluator';
@@ -1297,6 +1298,7 @@ export class PreAggregations {
12971298
const preAggQuery = this.query.preAggregationQueryForSqlEvaluation(cube, aggregation, { inPreAggEvaluation: true });
12981299
const aggregateMeasures = preAggQuery?.fullKeyQueryAggregateMeasures({ hasMultipliedForPreAggregation: true });
12991300
references.multipliedMeasures = aggregateMeasures?.multipliedMeasures?.map(m => m.measure);
1301+
references.joinTree = preAggQuery?.join;
13001302
}
13011303
if (aggregation.type === 'rollupLambda') {
13021304
if (references.rollups.length > 0) {

packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,25 @@ export type PreAggregationTimeDimensionReference = {
115115
granularity: string,
116116
};
117117

118+
// TODO: Move to JonGraph when it will be ts
119+
export type JoinEdge = {
120+
from: string;
121+
to: string;
122+
originalFrom: string;
123+
originalTo: string;
124+
join: {
125+
relationship: string; // TODO Use an enum from validator
126+
sql: Function,
127+
}
128+
};
129+
130+
// TODO: Move to JonGraph when it will be ts
131+
export type JoinTree = {
132+
root: string;
133+
joins: JoinEdge[];
134+
multiplicationFactor: Record<string, boolean>;
135+
};
136+
118137
/// Strings in `dimensions`, `measures` and `timeDimensions[*].dimension` can contain full join path, not just `cube.member`
119138
export type PreAggregationReferences = {
120139
allowNonStrictDateRangeMatch?: boolean,
@@ -123,6 +142,7 @@ export type PreAggregationReferences = {
123142
timeDimensions: Array<PreAggregationTimeDimensionReference>,
124143
rollups: Array<string>,
125144
multipliedMeasures?: Array<string>,
145+
joinTree?: JoinTree;
126146
};
127147

128148
export type PreAggregationInfo = {

0 commit comments

Comments
 (0)