Skip to content

Commit f69f933

Browse files
committed
another type fixes
1 parent 438d2da commit f69f933

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ import { BaseSegment } from './BaseSegment';
1717

1818
export type RollupJoin = any;
1919

20-
export type PreAggregationDefinitionExtended = PreAggregationDefinition & {
20+
export type PartitionTimeDimension = {
21+
dimension: string;
22+
dateRange: [string, string];
23+
boundaryDateRange: [string, string];
24+
};
25+
26+
export type PreAggregationDefinitionExtended = PreAggregationDefinition & PreAggregationReferences & {
2127
unionWithSourceData: boolean;
2228
rollupLambdaId: string;
2329
lastRollupLambda: boolean;
@@ -27,6 +33,7 @@ export type PreAggregationDefinitionExtended = PreAggregationDefinition & {
2733
streamOffset: 'earliest' | 'latest';
2834
uniqueKeyColumns: string;
2935
sqlAlias?: string;
36+
partitionTimeDimensions?: PartitionTimeDimension[];
3037
};
3138

3239
export type PreAggregationForQuery = {
@@ -587,7 +594,7 @@ export class PreAggregations {
587594
.dimensions
588595
.map(d => CubeSymbols.joinHintFromPath(d).path);
589596
const multipliedMeasuresTrimmed = references
590-
.multipliedMeasures?.map(m => CubeSymbols.joinHintFromPath(m).path);
597+
.multipliedMeasures?.map(m => CubeSymbols.joinHintFromPath(m).path) || [];
591598

592599
return {
593600
...references,
@@ -735,7 +742,7 @@ export class PreAggregations {
735742
if (referencesTrimmed.multipliedMeasures) {
736743
const backAliasMultipliedMeasures = backAlias(referencesTrimmed.multipliedMeasures);
737744

738-
if (transformedQuery.leafMeasures.some(m => referencesTrimmed.multipliedMeasures.includes(m)) ||
745+
if (transformedQuery.leafMeasures.some(m => referencesTrimmed.multipliedMeasures?.includes(m)) ||
739746
transformedQuery.measures.some(m => backAliasMultipliedMeasures.includes(m))
740747
) {
741748
return false;
@@ -1213,7 +1220,7 @@ export class PreAggregations {
12131220
);
12141221
}
12151222

1216-
public rollupPreAggregationQuery(cube: string, aggregation: PreAggregationDefinition, context: EvaluateReferencesContext = {}): BaseQuery {
1223+
public rollupPreAggregationQuery(cube: string, aggregation: PreAggregationDefinitionExtended, context: EvaluateReferencesContext = {}): BaseQuery {
12171224
// `this.evaluateAllReferences` will retain not only members, but their join path as well, and pass join hints
12181225
// to subquery. Otherwise, members in subquery would regenerate new join tree from clean state,
12191226
// and it can be different from expected by join path in pre-aggregation declaration
@@ -1245,7 +1252,7 @@ export class PreAggregations {
12451252
});
12461253
}
12471254

1248-
public autoRollupPreAggregationQuery(cube: string, aggregation: PreAggregationDefinition): BaseQuery {
1255+
public autoRollupPreAggregationQuery(cube: string, aggregation: PreAggregationDefinitionExtended): BaseQuery {
12491256
return this.query.newSubQueryForCube(
12501257
cube,
12511258
{
@@ -1261,7 +1268,7 @@ export class PreAggregations {
12611268
);
12621269
}
12631270

1264-
private mergePartitionTimeDimensions(aggregation: PreAggregationReferences, partitionTimeDimensions: BaseTimeDimension[]) {
1271+
private mergePartitionTimeDimensions(aggregation: PreAggregationReferences, partitionTimeDimensions?: PartitionTimeDimension[]) {
12651272
if (!partitionTimeDimensions) {
12661273
return aggregation.timeDimensions;
12671274
}
@@ -1286,7 +1293,7 @@ export class PreAggregations {
12861293
.toLowerCase();
12871294
}
12881295

1289-
private evaluateAllReferences(cube: string, aggregation: PreAggregationDefinition, preAggregationName: string | null = null, context: EvaluateReferencesOptions = {}): PreAggregationReferences {
1296+
private evaluateAllReferences(cube: string, aggregation: PreAggregationDefinition, preAggregationName: string | null = null, context: EvaluateReferencesContext = {}): PreAggregationReferences {
12901297
// TODO build a join tree for all references, so they would always include full join path
12911298
// Even for preaggregation references without join path
12921299
// It is necessary to be able to match query and preaggregation based on full join tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export type CubeRefreshKey =
9494
export type PreAggregationDefinition = {
9595
type: 'autoRollup' | 'originalSql' | 'rollupJoin' | 'rollupLambda' | 'rollup',
9696
allowNonStrictDateRangeMatch?: boolean,
97+
useOriginalSqlPreAggregations?: boolean,
9798
timeDimensionReference?: () => ToString,
9899
granularity: string,
99100
timeDimensionReferences: Array<{ dimension: () => ToString, granularity: string }>,

0 commit comments

Comments
 (0)