Skip to content

Commit 65b8bff

Browse files
committed
fix/specify some types
1 parent 6a5b563 commit 65b8bff

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationLoader.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import {
1212
UnloadOptions
1313
} from '@cubejs-backend/base-driver';
1414
import { DriverFactory } from './DriverFactory';
15-
import { QueryCache, QueryTuple } from './QueryCache';
15+
import { PreAggTableToTempTableNames, QueryCache, QueryTuple } from './QueryCache';
1616
import { ContinueWaitError } from './ContinueWaitError';
1717
import { LargeStreamWarning } from './StreamObjectsCounter';
1818
import {
1919
getStructureVersion,
2020
InvalidationKeys,
2121
LoadPreAggregationResult,
2222
PreAggregations,
23+
PreAggregationTableToTempTable,
2324
tablesToVersionEntries,
2425
version,
2526
VersionEntriesObj,
@@ -51,7 +52,7 @@ export class PreAggregationLoader {
5152

5253
public preAggregation: any;
5354

54-
private preAggregationsTablesToTempTables: any;
55+
private readonly preAggregationsTablesToTempTables: PreAggregationTableToTempTable[];
5556

5657
/**
5758
* Determines whether current instance instantiated for a jobbed build query
@@ -941,9 +942,10 @@ export class PreAggregationLoader {
941942
table_name: indexName
942943
};
943944
this.logger('Creating pre-aggregation index', queryOptions);
945+
const preAggTableToTempTableNames = this.preAggregationsTablesToTempTables as PreAggTableToTempTableNames[];
944946
const resultingSql = QueryCache.replacePreAggregationTableNames(
945947
query,
946-
this.preAggregationsTablesToTempTables.concat([
948+
preAggTableToTempTableNames.concat([
947949
[this.preAggregation.tableName, { targetTableName: this.targetTableName(newVersionEntry) }],
948950
[indexName, { targetTableName: this.targetTableName(indexVersionEntry) }]
949951
])

packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationPartitionRangeLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
PartitionRanges,
2323
PreAggregationDescription,
2424
PreAggregations,
25+
PreAggregationTableToTempTable,
2526
QueryDateRange
2627
} from './PreAggregations';
2728
import { PreAggregationLoader } from './PreAggregationLoader';
@@ -65,7 +66,7 @@ export class PreAggregationPartitionRangeLoader {
6566
private readonly queryCache: QueryCache,
6667
private readonly preAggregations: PreAggregations,
6768
private readonly preAggregation: PreAggregationDescription,
68-
private readonly preAggregationsTablesToTempTables: [string, LoadPreAggregationResult][],
69+
private readonly preAggregationsTablesToTempTables: PreAggregationTableToTempTable[],
6970
private readonly loadCache: PreAggregationLoadCache,
7071
private readonly options: PreAggsPartitionRangeLoaderOpts = {
7172
maxPartitions: 10000,

packages/cubejs-query-orchestrator/src/orchestrator/PreAggregations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ export type LoadPreAggregationResult = {
144144
partitionRange?: QueryDateRange;
145145
};
146146

147+
export type PreAggregationTableToTempTable = [string, LoadPreAggregationResult];
148+
147149
export type LambdaOptions = {
148150
maxSourceRows: number
149151
};

packages/cubejs-query-orchestrator/src/orchestrator/QueryCache.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { QueryQueue } from './QueryQueue';
1616
import { ContinueWaitError } from './ContinueWaitError';
1717
import { LocalCacheDriver } from './LocalCacheDriver';
1818
import { DriverFactory, DriverFactoryByDataSource } from './DriverFactory';
19-
import { PreAggregationDescription } from './PreAggregations';
19+
import { LoadPreAggregationResult, PreAggregationDescription } from './PreAggregations';
2020
import { getCacheHash } from './utils';
2121
import { CacheAndQueryDriverType } from './QueryOrchestrator';
2222

@@ -71,25 +71,7 @@ export type QueryBody = {
7171
/**
7272
* Temp (partition/lambda) table definition.
7373
*/
74-
export type TempTable = {
75-
type: string; // for ex.: "rollup"
76-
buildRangeEnd: string;
77-
lastUpdatedAt: number;
78-
queryKey: unknown;
79-
refreshKeyValues: [{
80-
'refresh_key': string,
81-
}][];
82-
targetTableName: string; // full table name (with suffix)
83-
lambdaTable?: {
84-
name: string,
85-
columns: {
86-
name: string,
87-
type: string,
88-
attributes?: string[],
89-
}[];
90-
csvRows: string;
91-
};
92-
};
74+
export type TempTable = LoadPreAggregationResult;
9375

9476
/**
9577
* Pre-aggregation table (stored in the first element) to temp table
@@ -100,6 +82,8 @@ export type PreAggTableToTempTable = [
10082
TempTable,
10183
];
10284

85+
export type PreAggTableToTempTableNames = [string, { targetTableName: string; }];
86+
10387
export type CacheKeyItem = string | string[] | QueryTuple | QueryTuple[] | undefined;
10488

10589
export type CacheKey =
@@ -397,7 +381,7 @@ export class QueryCache {
397381

398382
public static replacePreAggregationTableNames(
399383
queryAndParams: string | QueryWithParams,
400-
preAggregationsTablesToTempTables: PreAggTableToTempTable[],
384+
preAggregationsTablesToTempTables: PreAggTableToTempTableNames[],
401385
): string | QueryTuple {
402386
const [keyQuery, params, queryOptions] = Array.isArray(queryAndParams)
403387
? queryAndParams

0 commit comments

Comments
 (0)