@finos/legend-data-cube 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/view/grid/DataCubeGrid.d.ts.map +1 -1
- package/lib/components/view/grid/DataCubeGrid.js +20 -20
- package/lib/components/view/grid/DataCubeGrid.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/package.json +3 -3
- package/lib/stores/DataCubeAPI.d.ts +6 -0
- package/lib/stores/DataCubeAPI.d.ts.map +1 -1
- package/lib/stores/DataCubeAPI.js +3 -0
- package/lib/stores/DataCubeAPI.js.map +1 -1
- package/lib/stores/DataCubeOptions.d.ts +1 -1
- package/lib/stores/core/DataCubeConfigurationBuilder.js +1 -1
- package/lib/stores/core/DataCubeConfigurationBuilder.js.map +1 -1
- package/lib/stores/core/DataCubeEngine.d.ts +8 -5
- package/lib/stores/core/DataCubeEngine.d.ts.map +1 -1
- package/lib/stores/core/DataCubeEngine.js +31 -7
- package/lib/stores/core/DataCubeEngine.js.map +1 -1
- package/lib/stores/core/DataCubeQueryBuilder.d.ts +3 -4
- package/lib/stores/core/DataCubeQueryBuilder.d.ts.map +1 -1
- package/lib/stores/core/DataCubeQueryBuilder.js +19 -13
- package/lib/stores/core/DataCubeQueryBuilder.js.map +1 -1
- package/lib/stores/core/DataCubeQueryBuilderUtils.d.ts +2 -7
- package/lib/stores/core/DataCubeQueryBuilderUtils.d.ts.map +1 -1
- package/lib/stores/core/DataCubeQueryBuilderUtils.js +34 -46
- package/lib/stores/core/DataCubeQueryBuilderUtils.js.map +1 -1
- package/lib/stores/core/DataCubeQuerySnapshot.d.ts +11 -4
- package/lib/stores/core/DataCubeQuerySnapshot.d.ts.map +1 -1
- package/lib/stores/core/DataCubeQuerySnapshot.js +10 -0
- package/lib/stores/core/DataCubeQuerySnapshot.js.map +1 -1
- package/lib/stores/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -1
- package/lib/stores/core/DataCubeQuerySnapshotBuilder.js +1 -2
- package/lib/stores/core/DataCubeQuerySnapshotBuilder.js.map +1 -1
- package/lib/stores/core/DataCubeQuerySnapshotBuilderUtils.d.ts.map +1 -1
- package/lib/stores/core/DataCubeQuerySnapshotBuilderUtils.js +3 -3
- package/lib/stores/core/DataCubeQuerySnapshotBuilderUtils.js.map +1 -1
- package/lib/stores/core/model/CachedDataCubeSource.d.ts +4 -0
- package/lib/stores/core/model/CachedDataCubeSource.d.ts.map +1 -1
- package/lib/stores/core/model/CachedDataCubeSource.js +4 -0
- package/lib/stores/core/model/CachedDataCubeSource.js.map +1 -1
- package/lib/stores/services/DataCubeQuerySnapshotService.js +1 -1
- package/lib/stores/services/DataCubeQuerySnapshotService.js.map +1 -1
- package/lib/stores/services/DataCubeTaskService.d.ts.map +1 -1
- package/lib/stores/services/DataCubeTaskService.js +2 -0
- package/lib/stores/services/DataCubeTaskService.js.map +1 -1
- package/lib/stores/view/DataCubeViewState.d.ts +3 -1
- package/lib/stores/view/DataCubeViewState.d.ts.map +1 -1
- package/lib/stores/view/DataCubeViewState.js +46 -18
- package/lib/stores/view/DataCubeViewState.js.map +1 -1
- package/lib/stores/view/extend/DataCubeColumnEditorState.d.ts.map +1 -1
- package/lib/stores/view/extend/DataCubeColumnEditorState.js +7 -5
- package/lib/stores/view/extend/DataCubeColumnEditorState.js.map +1 -1
- package/lib/stores/view/grid/DataCubeGridClientEngine.d.ts.map +1 -1
- package/lib/stores/view/grid/DataCubeGridClientEngine.js +7 -4
- package/lib/stores/view/grid/DataCubeGridClientEngine.js.map +1 -1
- package/lib/stores/view/grid/DataCubeGridQueryBuilder.d.ts +3 -4
- package/lib/stores/view/grid/DataCubeGridQueryBuilder.d.ts.map +1 -1
- package/lib/stores/view/grid/DataCubeGridQueryBuilder.js +5 -5
- package/lib/stores/view/grid/DataCubeGridQueryBuilder.js.map +1 -1
- package/lib/stores/view/grid/DataCubeGridState.d.ts.map +1 -1
- package/lib/stores/view/grid/DataCubeGridState.js +18 -8
- package/lib/stores/view/grid/DataCubeGridState.js.map +1 -1
- package/package.json +7 -7
- package/src/components/view/grid/DataCubeGrid.tsx +8 -5
- package/src/index.tsx +8 -3
- package/src/stores/DataCubeAPI.ts +9 -0
- package/src/stores/DataCubeOptions.ts +1 -1
- package/src/stores/core/DataCubeConfigurationBuilder.ts +1 -1
- package/src/stores/core/DataCubeEngine.tsx +41 -20
- package/src/stores/core/DataCubeQueryBuilder.ts +38 -30
- package/src/stores/core/DataCubeQueryBuilderUtils.ts +42 -67
- package/src/stores/core/DataCubeQuerySnapshot.ts +15 -4
- package/src/stores/core/DataCubeQuerySnapshotBuilder.ts +2 -6
- package/src/stores/core/DataCubeQuerySnapshotBuilderUtils.ts +2 -3
- package/src/stores/core/model/CachedDataCubeSource.ts +4 -0
- package/src/stores/services/DataCubeQuerySnapshotService.ts +2 -2
- package/src/stores/services/DataCubeTaskService.ts +2 -0
- package/src/stores/view/DataCubeViewState.ts +46 -26
- package/src/stores/view/extend/DataCubeColumnEditorState.tsx +7 -15
- package/src/stores/view/grid/DataCubeGridClientEngine.ts +20 -26
- package/src/stores/view/grid/DataCubeGridQueryBuilder.ts +19 -32
- package/src/stores/view/grid/DataCubeGridState.ts +24 -8
|
@@ -73,10 +73,6 @@ import {
|
|
|
73
73
|
} from './DataCubeQuerySnapshotBuilderUtils.js';
|
|
74
74
|
import type { DataCubeSource } from './model/DataCubeSource.js';
|
|
75
75
|
import type { DataCubeEngine } from './DataCubeEngine.js';
|
|
76
|
-
import {
|
|
77
|
-
_deserializeValueSpecification,
|
|
78
|
-
_serializeValueSpecification,
|
|
79
|
-
} from './DataCubeQueryBuilderUtils.js';
|
|
80
76
|
|
|
81
77
|
// --------------------------------- BUILDING BLOCKS ---------------------------------
|
|
82
78
|
|
|
@@ -365,8 +361,8 @@ export async function validateAndBuildQuerySnapshot(
|
|
|
365
361
|
// analysis more ergonomic
|
|
366
362
|
|
|
367
363
|
// Clone the query since we will mutate it during the process
|
|
368
|
-
const query =
|
|
369
|
-
|
|
364
|
+
const query = engine.deserializeValueSpecification(
|
|
365
|
+
engine.serializeValueSpecification(partialQuery),
|
|
370
366
|
);
|
|
371
367
|
const funcMap = extractFunctionMap(query);
|
|
372
368
|
const snapshot = DataCubeQuerySnapshot.create({});
|
|
@@ -79,7 +79,6 @@ import {
|
|
|
79
79
|
_colSpec,
|
|
80
80
|
_function,
|
|
81
81
|
_lambda,
|
|
82
|
-
_serializeValueSpecification,
|
|
83
82
|
_synthesizeMinimalSourceQuery,
|
|
84
83
|
} from './DataCubeQueryBuilderUtils.js';
|
|
85
84
|
import { INTERNAL__DataCubeSource } from './model/DataCubeSource.js';
|
|
@@ -360,14 +359,14 @@ export async function _extractExtendedColumns(
|
|
|
360
359
|
_findCol(columns, colSpec.name),
|
|
361
360
|
`Can't process extend() expression: failed to retrieve type information for column '${colSpec.name}'`,
|
|
362
361
|
).type,
|
|
363
|
-
mapFn:
|
|
362
|
+
mapFn: engine.serializeValueSpecification(
|
|
364
363
|
guaranteeNonNullable(
|
|
365
364
|
colSpec.function1,
|
|
366
365
|
`Can't process extend() expression: expected a transformation function expression for column '${colSpec.name}'`,
|
|
367
366
|
),
|
|
368
367
|
),
|
|
369
368
|
reduceFn: colSpec.function2
|
|
370
|
-
?
|
|
369
|
+
? engine.serializeValueSpecification(colSpec.function2)
|
|
371
370
|
: undefined,
|
|
372
371
|
}));
|
|
373
372
|
}
|
|
@@ -88,8 +88,8 @@ export abstract class DataCubeQuerySnapshotController
|
|
|
88
88
|
this._engine.debugProcess(
|
|
89
89
|
`New Snapshot`,
|
|
90
90
|
['Publisher', this.getSnapshotSubscriberName()],
|
|
91
|
-
['Snapshot', snapshot],
|
|
92
|
-
['Previous Snapshot', previousSnapshot],
|
|
91
|
+
['Snapshot', snapshot.serialize()],
|
|
92
|
+
['Previous Snapshot', previousSnapshot?.serialize()],
|
|
93
93
|
['Diff', deepDiff(previousSnapshot ?? {}, snapshot)],
|
|
94
94
|
);
|
|
95
95
|
}
|
|
@@ -20,6 +20,8 @@ import { action, computed, makeObservable, observable } from 'mobx';
|
|
|
20
20
|
export class Task {
|
|
21
21
|
readonly uuid = uuid();
|
|
22
22
|
readonly name: string;
|
|
23
|
+
// use Date.now() vs. performance.now() because need to record the moment
|
|
24
|
+
// the task starts/ends for logging purposes.
|
|
23
25
|
readonly startTime = Date.now();
|
|
24
26
|
readonly ownerId?: string | undefined;
|
|
25
27
|
|
|
@@ -24,13 +24,6 @@ import {
|
|
|
24
24
|
import { DataCubeQuerySnapshotService } from '../services/DataCubeQuerySnapshotService.js';
|
|
25
25
|
import { DataCubeInfoState } from './DataCubeInfoState.js';
|
|
26
26
|
import { validateAndBuildQuerySnapshot } from '../core/DataCubeQuerySnapshotBuilder.js';
|
|
27
|
-
import {
|
|
28
|
-
action,
|
|
29
|
-
computed,
|
|
30
|
-
makeObservable,
|
|
31
|
-
observable,
|
|
32
|
-
runInAction,
|
|
33
|
-
} from 'mobx';
|
|
34
27
|
import { DataCubeFilterEditorState } from './filter/DataCubeFilterEditorState.js';
|
|
35
28
|
import { DataCubeExtendManagerState } from './extend/DataCubeExtendManagerState.js';
|
|
36
29
|
import type { DataCubeState } from '../DataCubeState.js';
|
|
@@ -43,6 +36,7 @@ import { DataCubeConfiguration } from '../core/model/DataCubeConfiguration.js';
|
|
|
43
36
|
import type { DataCubeLayoutService } from '../services/DataCubeLayoutService.js';
|
|
44
37
|
import type { DataCubeAlertService } from '../services/DataCubeAlertService.js';
|
|
45
38
|
import type { DataCubeSettingService } from '../services/DataCubeSettingService.js';
|
|
39
|
+
import { CachedDataCubeSource } from '../core/model/CachedDataCubeSource.js';
|
|
46
40
|
|
|
47
41
|
export class DataCubeViewState {
|
|
48
42
|
readonly dataCube: DataCubeState;
|
|
@@ -61,18 +55,12 @@ export class DataCubeViewState {
|
|
|
61
55
|
readonly extend: DataCubeExtendManagerState;
|
|
62
56
|
|
|
63
57
|
readonly initializeState = ActionState.create();
|
|
58
|
+
readonly processCacheState = ActionState.create();
|
|
64
59
|
|
|
65
60
|
private _source?: DataCubeSource | undefined;
|
|
66
61
|
private _originalSource?: DataCubeSource | undefined;
|
|
67
62
|
|
|
68
63
|
constructor(dataCube: DataCubeState) {
|
|
69
|
-
makeObservable<DataCubeViewState, '_source'>(this, {
|
|
70
|
-
_source: observable,
|
|
71
|
-
source: computed,
|
|
72
|
-
|
|
73
|
-
initialize: action,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
64
|
this.dataCube = dataCube;
|
|
77
65
|
this.engine = dataCube.engine;
|
|
78
66
|
this.logService = dataCube.logService;
|
|
@@ -93,6 +81,10 @@ export class DataCubeViewState {
|
|
|
93
81
|
this.extend = new DataCubeExtendManagerState(this);
|
|
94
82
|
}
|
|
95
83
|
|
|
84
|
+
getOriginalSource() {
|
|
85
|
+
return this._originalSource;
|
|
86
|
+
}
|
|
87
|
+
|
|
96
88
|
async generateDataCubeQuery() {
|
|
97
89
|
const snapshot = this.snapshotService.currentSnapshot;
|
|
98
90
|
const query = new DataCubeQuery();
|
|
@@ -112,18 +104,48 @@ export class DataCubeViewState {
|
|
|
112
104
|
}
|
|
113
105
|
|
|
114
106
|
async initializeCache() {
|
|
115
|
-
this.
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
this.processCacheState.inProgress();
|
|
108
|
+
const task = this.taskService.newTask('Initializing Cache');
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const cachedSource = await this.engine.initializeCache(this.source);
|
|
112
|
+
if (cachedSource) {
|
|
113
|
+
this._source = cachedSource;
|
|
114
|
+
}
|
|
115
|
+
this.processCacheState.pass();
|
|
116
|
+
} catch (error) {
|
|
117
|
+
assertErrorThrown(error);
|
|
118
|
+
this.alertService.alertError(error, {
|
|
119
|
+
message: `Cache Processing Failure: ${error.message}`,
|
|
120
|
+
});
|
|
121
|
+
this._source = this._originalSource;
|
|
122
|
+
this.processCacheState.fail();
|
|
123
|
+
} finally {
|
|
124
|
+
this.taskService.endTask(task);
|
|
120
125
|
}
|
|
121
|
-
this.initializeState.pass();
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
async
|
|
125
|
-
|
|
128
|
+
async disposeCache() {
|
|
129
|
+
if (!(this._source instanceof CachedDataCubeSource)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const cachedSource = this._source;
|
|
126
133
|
this._source = this._originalSource;
|
|
134
|
+
|
|
135
|
+
this.processCacheState.inProgress();
|
|
136
|
+
const task = this.taskService.newTask('Disposing Cache');
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
await this.engine.disposeCache(cachedSource);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
assertErrorThrown(error);
|
|
142
|
+
this.alertService.alertError(error, {
|
|
143
|
+
message: `Cache Processing Failure: ${error.message}`,
|
|
144
|
+
});
|
|
145
|
+
} finally {
|
|
146
|
+
this.processCacheState.complete();
|
|
147
|
+
this.taskService.endTask(task);
|
|
148
|
+
}
|
|
127
149
|
}
|
|
128
150
|
|
|
129
151
|
async initialize(query: DataCubeQuery) {
|
|
@@ -144,9 +166,8 @@ export class DataCubeViewState {
|
|
|
144
166
|
}),
|
|
145
167
|
);
|
|
146
168
|
const source = await this.engine.processQuerySource(query.source);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
169
|
+
this._source = source;
|
|
170
|
+
this._originalSource = source;
|
|
150
171
|
const partialQuery = await this.engine.parseValueSpecification(
|
|
151
172
|
query.query,
|
|
152
173
|
);
|
|
@@ -156,7 +177,6 @@ export class DataCubeViewState {
|
|
|
156
177
|
query,
|
|
157
178
|
this.engine,
|
|
158
179
|
);
|
|
159
|
-
this.engine.processInitialSnapshot?.(source, initialSnapshot);
|
|
160
180
|
this.snapshotService.broadcastSnapshot(initialSnapshot);
|
|
161
181
|
this.dataCube.options?.onViewInitialized?.({
|
|
162
182
|
api: this.dataCube.api,
|
|
@@ -47,11 +47,7 @@ import {
|
|
|
47
47
|
} from '@finos/legend-graph';
|
|
48
48
|
import type { DataCubeColumnConfiguration } from '../../core/model/DataCubeConfiguration.js';
|
|
49
49
|
import type { DataCubeQuerySnapshotExtendedColumn } from '../../core/DataCubeQuerySnapshot.js';
|
|
50
|
-
import {
|
|
51
|
-
_lambda,
|
|
52
|
-
_serializeValueSpecification,
|
|
53
|
-
_deserializeValueSpecification,
|
|
54
|
-
} from '../../core/DataCubeQueryBuilderUtils.js';
|
|
50
|
+
import { _lambda } from '../../core/DataCubeQueryBuilderUtils.js';
|
|
55
51
|
import { _findCol } from '../../core/model/DataCubeColumn.js';
|
|
56
52
|
|
|
57
53
|
export abstract class DataCubeColumnBaseEditorState {
|
|
@@ -220,13 +216,9 @@ export abstract class DataCubeColumnBaseEditorState {
|
|
|
220
216
|
return _lambda(
|
|
221
217
|
[],
|
|
222
218
|
[
|
|
223
|
-
buildExecutableQuery(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
() => undefined,
|
|
227
|
-
this.view.engine.filterOperations,
|
|
228
|
-
this.view.engine.aggregateOperations,
|
|
229
|
-
),
|
|
219
|
+
buildExecutableQuery(snapshot, this.view.source, this.view.engine, {
|
|
220
|
+
skipExecutionContext: true,
|
|
221
|
+
}),
|
|
230
222
|
],
|
|
231
223
|
);
|
|
232
224
|
}
|
|
@@ -390,7 +382,7 @@ export class DataCubeNewColumnState extends DataCubeColumnBaseEditorState {
|
|
|
390
382
|
{
|
|
391
383
|
name: this.name,
|
|
392
384
|
type: returnType,
|
|
393
|
-
mapFn:
|
|
385
|
+
mapFn: this.view.engine.serializeValueSpecification(query),
|
|
394
386
|
},
|
|
395
387
|
this.isGroupLevel,
|
|
396
388
|
this.columnKind,
|
|
@@ -440,7 +432,7 @@ export class DataCubeExistingColumnEditorState extends DataCubeColumnBaseEditorS
|
|
|
440
432
|
|
|
441
433
|
override async getInitialCode(): Promise<string> {
|
|
442
434
|
return this.view.engine.getValueSpecificationCode(
|
|
443
|
-
|
|
435
|
+
this.view.engine.deserializeValueSpecification(this.initialData.mapFn),
|
|
444
436
|
true,
|
|
445
437
|
);
|
|
446
438
|
}
|
|
@@ -516,7 +508,7 @@ export class DataCubeExistingColumnEditorState extends DataCubeColumnBaseEditorS
|
|
|
516
508
|
{
|
|
517
509
|
name: this.name,
|
|
518
510
|
type: returnType,
|
|
519
|
-
mapFn:
|
|
511
|
+
mapFn: this.view.engine.serializeValueSpecification(query),
|
|
520
512
|
},
|
|
521
513
|
this.isGroupLevel,
|
|
522
514
|
this.columnKind,
|
|
@@ -265,29 +265,15 @@ async function getCastColumns(
|
|
|
265
265
|
snapshot.data.groupExtendedColumns = [];
|
|
266
266
|
snapshot.data.sortColumns = [];
|
|
267
267
|
snapshot.data.limit = 0;
|
|
268
|
-
const query = buildExecutableQuery(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
postProcessor: (
|
|
276
|
-
_snapshot,
|
|
277
|
-
sequence,
|
|
278
|
-
funcMap,
|
|
279
|
-
configuration,
|
|
280
|
-
filterOperations,
|
|
281
|
-
aggregateOperations,
|
|
282
|
-
) => {
|
|
283
|
-
// when both pivot and groupBy present, we need to account for the count column
|
|
284
|
-
// in the cast expression
|
|
285
|
-
if (funcMap.pivot && currentSnapshot.data.groupBy) {
|
|
286
|
-
_colSpecArrayParam(funcMap.pivot, 1).colSpecs.push(_aggCountCol());
|
|
287
|
-
}
|
|
288
|
-
},
|
|
268
|
+
const query = buildExecutableQuery(snapshot, view.source, view.engine, {
|
|
269
|
+
postProcessor: (_snapshot, sequence, funcMap, configuration, engine) => {
|
|
270
|
+
// when both pivot and groupBy present, we need to account for the count column
|
|
271
|
+
// in the cast expression
|
|
272
|
+
if (funcMap.pivot && currentSnapshot.data.groupBy) {
|
|
273
|
+
_colSpecArrayParam(funcMap.pivot, 1).colSpecs.push(_aggCountCol());
|
|
274
|
+
}
|
|
289
275
|
},
|
|
290
|
-
);
|
|
276
|
+
});
|
|
291
277
|
|
|
292
278
|
const lambda = new V1_Lambda();
|
|
293
279
|
lambda.body.push(query);
|
|
@@ -413,13 +399,22 @@ export class DataCubeGridClientServerSideDataSource
|
|
|
413
399
|
request,
|
|
414
400
|
newSnapshot,
|
|
415
401
|
this._view.source,
|
|
416
|
-
|
|
417
|
-
this._view.engine.filterOperations,
|
|
418
|
-
this._view.engine.aggregateOperations,
|
|
402
|
+
this._view.engine,
|
|
419
403
|
this._grid.isPaginationEnabled,
|
|
420
404
|
);
|
|
421
405
|
const lambda = new V1_Lambda();
|
|
422
406
|
lambda.body.push(executableQuery);
|
|
407
|
+
if (
|
|
408
|
+
this._view.settingService.getBooleanValue(
|
|
409
|
+
DataCubeSettingKey.DEBUGGER__ENABLE_DEBUG_MODE,
|
|
410
|
+
)
|
|
411
|
+
) {
|
|
412
|
+
this._view.engine.debugProcess(
|
|
413
|
+
`Execution Plan`,
|
|
414
|
+
['Query', lambda],
|
|
415
|
+
['Config', `pagination=${this._grid.isPaginationEnabled}`],
|
|
416
|
+
);
|
|
417
|
+
}
|
|
423
418
|
const result = await this._view.engine.executeQuery(
|
|
424
419
|
lambda,
|
|
425
420
|
this._view.source,
|
|
@@ -443,7 +438,6 @@ export class DataCubeGridClientServerSideDataSource
|
|
|
443
438
|
this._view.engine.debugProcess(
|
|
444
439
|
`Execution`,
|
|
445
440
|
['Query', result.executedQuery],
|
|
446
|
-
['Config', `pagination=${this._grid.isPaginationEnabled}`],
|
|
447
441
|
[
|
|
448
442
|
'Stats',
|
|
449
443
|
`${rowData.length} rows, ${result.result.result.columns.length} columns`,
|
|
@@ -60,11 +60,10 @@ import {
|
|
|
60
60
|
type DataCubeGridClientDataFetchRequest,
|
|
61
61
|
} from './DataCubeGridClientEngine.js';
|
|
62
62
|
import { DataCubeConfiguration } from '../../core/model/DataCubeConfiguration.js';
|
|
63
|
-
import type { DataCubeQueryFilterOperation } from '../../core/filter/DataCubeQueryFilterOperation.js';
|
|
64
|
-
import type { DataCubeQueryAggregateOperation } from '../../core/aggregation/DataCubeQueryAggregateOperation.js';
|
|
65
63
|
import { _colSpecArrayParam } from '../../core/DataCubeQuerySnapshotBuilderUtils.js';
|
|
66
64
|
import { buildExecutableQuery } from '../../core/DataCubeQueryBuilder.js';
|
|
67
65
|
import type { DataCubeSource } from '../../core/model/DataCubeSource.js';
|
|
66
|
+
import type { DataCubeEngine } from '../../core/DataCubeEngine.js';
|
|
68
67
|
|
|
69
68
|
/*****************************************************************************
|
|
70
69
|
* [GRID]
|
|
@@ -148,11 +147,7 @@ export function buildGridDataFetchExecutableQuery(
|
|
|
148
147
|
request: DataCubeGridClientDataFetchRequest,
|
|
149
148
|
snapshot: DataCubeQuerySnapshot,
|
|
150
149
|
source: DataCubeSource,
|
|
151
|
-
|
|
152
|
-
source: DataCubeSource,
|
|
153
|
-
) => V1_AppliedFunction | undefined,
|
|
154
|
-
filterOperations: DataCubeQueryFilterOperation[],
|
|
155
|
-
aggregateOperations: DataCubeQueryAggregateOperation[],
|
|
150
|
+
engine: DataCubeEngine,
|
|
156
151
|
enablePagination: boolean,
|
|
157
152
|
) {
|
|
158
153
|
const processedSnapshot = snapshot.clone();
|
|
@@ -170,28 +165,21 @@ export function buildGridDataFetchExecutableQuery(
|
|
|
170
165
|
],
|
|
171
166
|
};
|
|
172
167
|
}
|
|
173
|
-
return buildExecutableQuery(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
filterOperations,
|
|
178
|
-
aggregateOperations,
|
|
179
|
-
{
|
|
180
|
-
postProcessor: generateGridDataFetchExecutableQueryPostProcessor(request),
|
|
181
|
-
rootAggregation: {
|
|
182
|
-
columnName: INTERNAL__GRID_CLIENT_ROOT_AGGREGATION_COLUMN_ID,
|
|
183
|
-
},
|
|
184
|
-
pagination:
|
|
185
|
-
enablePagination &&
|
|
186
|
-
request.startRow !== undefined &&
|
|
187
|
-
request.endRow !== undefined
|
|
188
|
-
? {
|
|
189
|
-
start: request.startRow,
|
|
190
|
-
end: request.endRow,
|
|
191
|
-
}
|
|
192
|
-
: undefined,
|
|
168
|
+
return buildExecutableQuery(processedSnapshot, source, engine, {
|
|
169
|
+
postProcessor: generateGridDataFetchExecutableQueryPostProcessor(request),
|
|
170
|
+
rootAggregation: {
|
|
171
|
+
columnName: INTERNAL__GRID_CLIENT_ROOT_AGGREGATION_COLUMN_ID,
|
|
193
172
|
},
|
|
194
|
-
|
|
173
|
+
pagination:
|
|
174
|
+
enablePagination &&
|
|
175
|
+
request.startRow !== undefined &&
|
|
176
|
+
request.endRow !== undefined
|
|
177
|
+
? {
|
|
178
|
+
start: request.startRow,
|
|
179
|
+
end: request.endRow,
|
|
180
|
+
}
|
|
181
|
+
: undefined,
|
|
182
|
+
});
|
|
195
183
|
}
|
|
196
184
|
|
|
197
185
|
function generateGridDataFetchExecutableQueryPostProcessor(
|
|
@@ -202,8 +190,7 @@ function generateGridDataFetchExecutableQueryPostProcessor(
|
|
|
202
190
|
sequence: V1_AppliedFunction[],
|
|
203
191
|
funcMap: DataCubeQueryFunctionMap,
|
|
204
192
|
configuration: DataCubeConfiguration,
|
|
205
|
-
|
|
206
|
-
aggregateOperations: DataCubeQueryAggregateOperation[],
|
|
193
|
+
engine: DataCubeEngine,
|
|
207
194
|
) => {
|
|
208
195
|
const _unprocess = _functionCompositionUnProcessor(sequence, funcMap);
|
|
209
196
|
const data = snapshot.data;
|
|
@@ -285,7 +272,7 @@ function generateGridDataFetchExecutableQueryPostProcessor(
|
|
|
285
272
|
}),
|
|
286
273
|
groupOperator: DataCubeQueryFilterGroupOperator.AND,
|
|
287
274
|
},
|
|
288
|
-
filterOperations,
|
|
275
|
+
engine.filterOperations,
|
|
289
276
|
),
|
|
290
277
|
],
|
|
291
278
|
),
|
|
@@ -312,7 +299,7 @@ function generateGridDataFetchExecutableQueryPostProcessor(
|
|
|
312
299
|
groupByColumns,
|
|
313
300
|
snapshot,
|
|
314
301
|
configuration,
|
|
315
|
-
aggregateOperations,
|
|
302
|
+
engine.aggregateOperations,
|
|
316
303
|
),
|
|
317
304
|
|
|
318
305
|
// if pivot is present, add sum aggregation columns for each
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
guaranteeNonNullable,
|
|
20
20
|
type DebouncedFunc,
|
|
21
21
|
} from '@finos/legend-shared';
|
|
22
|
-
import { action, makeObservable, observable } from 'mobx';
|
|
22
|
+
import { action, makeObservable, observable, runInAction } from 'mobx';
|
|
23
23
|
import type { GridApi } from 'ag-grid-community';
|
|
24
24
|
import type { DataCubeViewState } from '../DataCubeViewState.js';
|
|
25
25
|
import {
|
|
@@ -125,16 +125,32 @@ export class DataCubeGridState extends DataCubeQuerySnapshotController {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
async setCachingEnabled(val: boolean) {
|
|
128
|
-
this.isCachingEnabled
|
|
129
|
-
if (
|
|
130
|
-
|
|
128
|
+
const currentVal = this.isCachingEnabled;
|
|
129
|
+
if (val === currentVal) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
runInAction(() => {
|
|
134
|
+
this.isCachingEnabled = val;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (val) {
|
|
131
138
|
await this._view.initializeCache();
|
|
132
|
-
this.
|
|
139
|
+
if (this._view.processCacheState.hasFailed) {
|
|
140
|
+
this.isCachingEnabled = currentVal;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
133
143
|
} else {
|
|
134
|
-
this.
|
|
135
|
-
await this._view.clearCache();
|
|
136
|
-
this._client?.setGridOption('loading', false);
|
|
144
|
+
await this._view.disposeCache();
|
|
137
145
|
}
|
|
146
|
+
|
|
147
|
+
runInAction(() => {
|
|
148
|
+
// hard reset the grid, this will force the grid to fetch data again
|
|
149
|
+
this.clientDataSource = new DataCubeGridClientServerSideDataSource(
|
|
150
|
+
this,
|
|
151
|
+
this._view,
|
|
152
|
+
);
|
|
153
|
+
});
|
|
138
154
|
}
|
|
139
155
|
|
|
140
156
|
setScrollHintText(val: string | undefined) {
|