@finos/legend-data-cube 0.1.5 → 0.1.7

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.
Files changed (61) hide show
  1. package/lib/components/core/DataCubeExecutionErrorAlert.d.ts +23 -0
  2. package/lib/components/core/DataCubeExecutionErrorAlert.d.ts.map +1 -0
  3. package/lib/components/core/DataCubeExecutionErrorAlert.js +40 -0
  4. package/lib/components/core/DataCubeExecutionErrorAlert.js.map +1 -0
  5. package/lib/components/core/DataCubeFormUtils.d.ts +6 -0
  6. package/lib/components/core/DataCubeFormUtils.d.ts.map +1 -1
  7. package/lib/components/core/DataCubeFormUtils.js +6 -1
  8. package/lib/components/core/DataCubeFormUtils.js.map +1 -1
  9. package/lib/components/view/editor/DataCubeEditorColumnPropertiesPanel.js +1 -1
  10. package/lib/components/view/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -1
  11. package/lib/components/view/editor/DataCubeEditorDimensionsPanel.d.ts +32 -0
  12. package/lib/components/view/editor/DataCubeEditorDimensionsPanel.d.ts.map +1 -0
  13. package/lib/components/view/editor/DataCubeEditorDimensionsPanel.js +311 -0
  14. package/lib/components/view/editor/DataCubeEditorDimensionsPanel.js.map +1 -0
  15. package/lib/components/view/grid/DataCubeMultidimensionalGrid.d.ts +22 -0
  16. package/lib/components/view/grid/DataCubeMultidimensionalGrid.d.ts.map +1 -0
  17. package/lib/components/view/grid/DataCubeMultidimensionalGrid.js +20 -0
  18. package/lib/components/view/grid/DataCubeMultidimensionalGrid.js.map +1 -0
  19. package/lib/index.css +1 -1
  20. package/lib/package.json +6 -6
  21. package/lib/stores/core/DataCubeEngine.d.ts +5 -1
  22. package/lib/stores/core/DataCubeEngine.d.ts.map +1 -1
  23. package/lib/stores/core/DataCubeEngine.js +7 -1
  24. package/lib/stores/core/DataCubeEngine.js.map +1 -1
  25. package/lib/stores/core/model/AdhocQueryDataCubeSource.d.ts +3 -2
  26. package/lib/stores/core/model/AdhocQueryDataCubeSource.d.ts.map +1 -1
  27. package/lib/stores/core/model/AdhocQueryDataCubeSource.js.map +1 -1
  28. package/lib/stores/core/model/CachedDataCubeSource.d.ts +2 -2
  29. package/lib/stores/core/model/CachedDataCubeSource.d.ts.map +1 -1
  30. package/lib/stores/core/model/CachedDataCubeSource.js +0 -1
  31. package/lib/stores/core/model/CachedDataCubeSource.js.map +1 -1
  32. package/lib/stores/services/DataCubeAlertService.d.ts +2 -0
  33. package/lib/stores/services/DataCubeAlertService.d.ts.map +1 -1
  34. package/lib/stores/services/DataCubeAlertService.js +13 -0
  35. package/lib/stores/services/DataCubeAlertService.js.map +1 -1
  36. package/lib/stores/view/DataCubeViewState.d.ts.map +1 -1
  37. package/lib/stores/view/DataCubeViewState.js +2 -1
  38. package/lib/stores/view/DataCubeViewState.js.map +1 -1
  39. package/lib/stores/view/editor/DataCubeEditorDimensionsPanelState.d.ts +34 -0
  40. package/lib/stores/view/editor/DataCubeEditorDimensionsPanelState.d.ts.map +1 -0
  41. package/lib/stores/view/editor/DataCubeEditorDimensionsPanelState.js +86 -0
  42. package/lib/stores/view/editor/DataCubeEditorDimensionsPanelState.js.map +1 -0
  43. package/lib/stores/view/grid/DataCubeGridClientEngine.d.ts.map +1 -1
  44. package/lib/stores/view/grid/DataCubeGridClientEngine.js +23 -6
  45. package/lib/stores/view/grid/DataCubeGridClientEngine.js.map +1 -1
  46. package/lib/stores/view/grid/DataCubeGridConfigurationBuilder.d.ts +2 -0
  47. package/lib/stores/view/grid/DataCubeGridConfigurationBuilder.d.ts.map +1 -1
  48. package/package.json +11 -11
  49. package/src/components/core/DataCubeExecutionErrorAlert.tsx +134 -0
  50. package/src/components/core/DataCubeFormUtils.tsx +37 -2
  51. package/src/components/view/editor/DataCubeEditorColumnPropertiesPanel.tsx +1 -1
  52. package/src/components/view/editor/DataCubeEditorDimensionsPanel.tsx +606 -0
  53. package/src/components/view/grid/DataCubeMultidimensionalGrid.tsx +24 -0
  54. package/src/stores/core/DataCubeEngine.tsx +9 -1
  55. package/src/stores/core/model/AdhocQueryDataCubeSource.ts +3 -2
  56. package/src/stores/core/model/CachedDataCubeSource.ts +2 -3
  57. package/src/stores/services/DataCubeAlertService.tsx +27 -0
  58. package/src/stores/view/DataCubeViewState.ts +1 -0
  59. package/src/stores/view/editor/DataCubeEditorDimensionsPanelState.ts +134 -0
  60. package/src/stores/view/grid/DataCubeGridClientEngine.ts +24 -7
  61. package/tsconfig.json +4 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { observer } from 'mobx-react-lite';
18
+ import type { DataCubeViewState } from '../../../stores/view/DataCubeViewState.js';
19
+
20
+ export const DataCubeMultidimensionalGrid = observer(
21
+ (props: { view: DataCubeViewState }) => {
22
+ return null;
23
+ },
24
+ );
@@ -22,6 +22,7 @@ import {
22
22
  PRIMITIVE_TYPE,
23
23
  V1_deserializeValueSpecification,
24
24
  V1_serializeValueSpecification,
25
+ type V1_ExecuteInput,
25
26
  } from '@finos/legend-graph';
26
27
  import {
27
28
  getFilterOperation,
@@ -113,6 +114,11 @@ export type DataCubeExecutionResult = {
113
114
  executionTime: number;
114
115
  };
115
116
 
117
+ export class DataCubeExecutionError extends Error {
118
+ executeInput?: PlainObject<V1_ExecuteInput> | undefined;
119
+ queryCode?: string | undefined;
120
+ }
121
+
116
122
  /**
117
123
  * This is the base engine of DataCube, it provides capabilities that DataCube cannot itself
118
124
  * handle, such as query execution, compilation, etc.
@@ -279,7 +285,9 @@ export abstract class DataCubeEngine {
279
285
  return undefined;
280
286
  }
281
287
 
282
- async disposeCache(source: CachedDataCubeSource) {}
288
+ async disposeCache(source: CachedDataCubeSource) {
289
+ // do nothing
290
+ }
283
291
 
284
292
  // ---------------------------------- APPLICATION ----------------------------------
285
293
 
@@ -21,10 +21,11 @@ import {
21
21
  } from '@finos/legend-shared';
22
22
  import { DataCubeSource } from './DataCubeSource.js';
23
23
  import { createModelSchema, primitive, raw } from 'serializr';
24
+ import type { V1_PureModelContext } from '@finos/legend-graph';
24
25
 
25
26
  export class AdhocQueryDataCubeSource extends DataCubeSource {
26
27
  runtime!: string;
27
- model!: PlainObject;
28
+ model!: PlainObject<V1_PureModelContext>;
28
29
  }
29
30
 
30
31
  export const ADHOC_QUERY_DATA_CUBE_SOURCE_TYPE = 'adhocQuery';
@@ -32,7 +33,7 @@ export const ADHOC_QUERY_DATA_CUBE_SOURCE_TYPE = 'adhocQuery';
32
33
  export class RawAdhocQueryDataCubeSource {
33
34
  query!: string;
34
35
  runtime!: string;
35
- model!: PlainObject;
36
+ model!: PlainObject<V1_PureModelContext>;
36
37
 
37
38
  static readonly serialization = new SerializationFactory(
38
39
  createModelSchema(RawAdhocQueryDataCubeSource, {
@@ -16,11 +16,10 @@
16
16
 
17
17
  import type { V1_PureModelContextData } from '@finos/legend-graph';
18
18
  import { DataCubeSource } from './DataCubeSource.js';
19
-
20
- export const CACHED_DATA_CUBE_SOURCE_TYPE = 'cached';
19
+ import type { PlainObject } from '@finos/legend-shared';
21
20
 
22
21
  export class CachedDataCubeSource extends DataCubeSource {
23
- model!: V1_PureModelContextData;
22
+ model!: PlainObject<V1_PureModelContextData>;
24
23
  runtime!: string;
25
24
  db!: string;
26
25
  schema!: string;
@@ -28,6 +28,8 @@ import { editor as monacoEditorAPI, Uri } from 'monaco-editor';
28
28
  import { DataCubeCodeCheckErrorAlert } from '../../components/core/DataCubeCodeCheckErrorAlert.js';
29
29
  import { uuid } from '@finos/legend-shared';
30
30
  import type { DataCubeLogService } from './DataCubeLogService.js';
31
+ import type { DataCubeExecutionError } from '../core/DataCubeEngine.js';
32
+ import { DataCubeExecutionErrorAlert } from '../../components/core/DataCubeExecutionErrorAlert.js';
31
33
 
32
34
  export enum AlertType {
33
35
  ERROR = 'ERROR',
@@ -166,4 +168,29 @@ export class DataCubeAlertService {
166
168
  this._layoutService.newWindow(window);
167
169
  }
168
170
  }
171
+
172
+ alertExecutionError(
173
+ error: DataCubeExecutionError,
174
+ options: ActionAlertOptions,
175
+ ) {
176
+ const { message, text, windowTitle, windowConfig } = options;
177
+ const window = new WindowState(
178
+ new LayoutConfiguration(windowTitle ?? 'Error', () => (
179
+ <DataCubeExecutionErrorAlert
180
+ error={error}
181
+ message={message}
182
+ text={text}
183
+ onClose={() => this._layoutService.closeWindow(window)}
184
+ />
185
+ )),
186
+ );
187
+ window.configuration.window = windowConfig ?? {
188
+ width: 600,
189
+ height: 250, // leave some space to show debug content
190
+ minWidth: 500,
191
+ minHeight: 200,
192
+ center: true,
193
+ };
194
+ this._layoutService.newWindow(window);
195
+ }
169
196
  }
@@ -261,6 +261,7 @@ export class DataCubeViewState {
261
261
  });
262
262
 
263
263
  if (
264
+ this.grid.isCachingEnabled &&
264
265
  this.settingService.getBooleanValue(
265
266
  DataCubeSettingKey.GRID_CLIENT__SHOW_AUTO_ENABLE_CACHE_PERFORMANCE_WARNING,
266
267
  )
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type { DataCubeConfiguration } from '../../core/model/DataCubeConfiguration.js';
18
+ import { DataCubeColumnKind } from '../../core/DataCubeQueryEngine.js';
19
+ import { type DataCubeSnapshot } from '../../core/DataCubeSnapshot.js';
20
+ import { _findCol } from '../../core/model/DataCubeColumn.js';
21
+ import {
22
+ DataCubeEditorColumnSelectorColumnState,
23
+ DataCubeEditorColumnSelectorState,
24
+ } from './DataCubeEditorColumnSelectorState.js';
25
+ import type { DataCubeQueryEditorPanelState } from './DataCubeEditorPanelState.js';
26
+ import type { DataCubeEditorState } from './DataCubeEditorState.js';
27
+ import { action, computed, makeObservable, observable } from 'mobx';
28
+
29
+ export class DataCubeEditorVerticalPivotColumnSelectorState extends DataCubeEditorColumnSelectorState<DataCubeEditorColumnSelectorColumnState> {
30
+ override cloneColumn(
31
+ column: DataCubeEditorColumnSelectorColumnState,
32
+ ): DataCubeEditorColumnSelectorColumnState {
33
+ return new DataCubeEditorColumnSelectorColumnState(
34
+ column.name,
35
+ column.type,
36
+ );
37
+ }
38
+
39
+ override get availableColumns() {
40
+ return this._editor.columnProperties.columns
41
+ .filter(
42
+ (column) =>
43
+ column.kind === DataCubeColumnKind.DIMENSION &&
44
+ // exclude group-level extended columns
45
+ !_findCol(this._editor.groupExtendColumns, column.name) &&
46
+ // exclude pivot columns
47
+ !_findCol(
48
+ this._editor.horizontalPivots.selector.selectedColumns,
49
+ column.name,
50
+ ),
51
+ )
52
+ .map(
53
+ (col) =>
54
+ new DataCubeEditorColumnSelectorColumnState(col.name, col.type),
55
+ );
56
+ }
57
+
58
+ //
59
+ }
60
+
61
+ export class DataCubeEditorDimensionsPanelState
62
+ implements DataCubeQueryEditorPanelState
63
+ {
64
+ readonly _editor!: DataCubeEditorState;
65
+
66
+ availableColumnsSearchText = '';
67
+ // readonly selector!: DataCubeEditorVerticalPivotColumnSelectorState;
68
+
69
+ constructor(editor: DataCubeEditorState) {
70
+ makeObservable(this, {
71
+ availableColumnsSearchText: observable,
72
+ setAvailableColumnsSearchText: action,
73
+
74
+ availableColumns: computed,
75
+ });
76
+
77
+ this._editor = editor;
78
+ }
79
+
80
+ get availableColumns() {
81
+ return this._editor.columnProperties.columns
82
+ .filter(
83
+ (column) =>
84
+ column.kind === DataCubeColumnKind.DIMENSION &&
85
+ // exclude group-level extended columns
86
+ !_findCol(this._editor.groupExtendColumns, column.name) &&
87
+ // exclude pivot columns
88
+ !_findCol(
89
+ this._editor.horizontalPivots.selector.selectedColumns,
90
+ column.name,
91
+ ),
92
+ )
93
+ .map(
94
+ (col) =>
95
+ new DataCubeEditorColumnSelectorColumnState(col.name, col.type),
96
+ );
97
+ }
98
+
99
+ setAvailableColumnsSearchText(val: string) {
100
+ this.availableColumnsSearchText = val;
101
+ }
102
+
103
+ // adaptPropagatedChanges(): void {
104
+ // this.selector.setSelectedColumns(
105
+ // this.selector.selectedColumns.filter((column) =>
106
+ // _findCol(this.selector.availableColumns, column.name),
107
+ // ),
108
+ // );
109
+ // }
110
+
111
+ applySnaphot(
112
+ snapshot: DataCubeSnapshot,
113
+ configuration: DataCubeConfiguration,
114
+ ) {
115
+ // this.selector.setSelectedColumns(
116
+ // (snapshot.data.groupBy?.columns ?? []).map(
117
+ // (col) =>
118
+ // new DataCubeEditorColumnSelectorColumnState(col.name, col.type),
119
+ // ),
120
+ // );
121
+ }
122
+
123
+ buildSnapshot(newSnapshot: DataCubeSnapshot, baseSnapshot: DataCubeSnapshot) {
124
+ // newSnapshot.data.groupBy = this.selector.selectedColumns.length
125
+ // ? {
126
+ // columns: this.selector.selectedColumns.map(_toCol),
127
+ // }
128
+ // : undefined;
129
+ // newSnapshot.data.selectColumns = uniqBy(
130
+ // [...newSnapshot.data.selectColumns, ...this.selector.selectedColumns],
131
+ // (col) => col.name,
132
+ // ).map(_toCol);
133
+ }
134
+ }
@@ -50,7 +50,10 @@ import type { DataCubeViewState } from '../DataCubeViewState.js';
50
50
  import { buildGridDataFetchExecutableQuery } from './DataCubeGridQueryBuilder.js';
51
51
  import { DataCubeSettingKey } from '../../../__lib__/DataCubeSetting.js';
52
52
  import { DEFAULT_ALERT_WINDOW_CONFIG } from '../../services/DataCubeLayoutService.js';
53
- import type { DataCubeExecutionResult } from '../../core/DataCubeEngine.js';
53
+ import {
54
+ DataCubeExecutionError,
55
+ type DataCubeExecutionResult,
56
+ } from '../../core/DataCubeEngine.js';
54
57
  import { _lambda } from '../../core/DataCubeQueryBuilderUtils.js';
55
58
  import { sum } from 'mathjs';
56
59
 
@@ -365,9 +368,16 @@ export class DataCubeGridClientServerSideDataSource
365
368
  );
366
369
  } catch (error) {
367
370
  assertErrorThrown(error);
368
- this._view.alertService.alertError(error, {
369
- message: `Query Validation Failure: Can't retrieve pivot results column metadata. ${error.message}`,
370
- });
371
+ if (error instanceof DataCubeExecutionError) {
372
+ this._view.alertService.alertExecutionError(error, {
373
+ message: `Query Validation Failure: Can't retrieve pivot results column metadata.`,
374
+ text: `Error: ${error.message}`,
375
+ });
376
+ } else {
377
+ this._view.alertService.alertError(error, {
378
+ message: `Query Validation Failure: Can't retrieve pivot results column metadata. ${error.message}`,
379
+ });
380
+ }
371
381
  // fail early since we can't proceed without the cast columns validated
372
382
  params.fail();
373
383
  this._view.taskService.endTask(task);
@@ -418,9 +428,16 @@ export class DataCubeGridClientServerSideDataSource
418
428
  rowData = buildRowData(result.result.result, newSnapshot);
419
429
  } catch (error) {
420
430
  assertErrorThrown(error);
421
- this._view.alertService.alertError(error, {
422
- message: `Data Fetch Failure: ${error.message}`,
423
- });
431
+ if (error instanceof DataCubeExecutionError) {
432
+ this._view.alertService.alertExecutionError(error, {
433
+ message: `Data Fetch Failure: Can't execute query.`,
434
+ text: `Error: ${error.message}`,
435
+ });
436
+ } else {
437
+ this._view.alertService.alertError(error, {
438
+ message: `Data Fetch Failure: ${error.message}`,
439
+ });
440
+ }
424
441
  this._view.taskService.endTask(task);
425
442
  params.fail();
426
443
  return;
package/tsconfig.json CHANGED
@@ -82,6 +82,7 @@
82
82
  "./src/stores/view/editor/DataCubeEditorColumnPropertiesPanelState.ts",
83
83
  "./src/stores/view/editor/DataCubeEditorColumnSelectorState.ts",
84
84
  "./src/stores/view/editor/DataCubeEditorColumnsPanelState.ts",
85
+ "./src/stores/view/editor/DataCubeEditorDimensionsPanelState.ts",
85
86
  "./src/stores/view/editor/DataCubeEditorGeneralPropertiesPanelState.ts",
86
87
  "./src/stores/view/editor/DataCubeEditorHorizontalPivotsPanelState.ts",
87
88
  "./src/stores/view/editor/DataCubeEditorMutableConfiguration.ts",
@@ -105,6 +106,7 @@
105
106
  "./src/components/core/DataCubeAlert.tsx",
106
107
  "./src/components/core/DataCubeCodeCheckErrorAlert.tsx",
107
108
  "./src/components/core/DataCubeDocumentationPanel.tsx",
109
+ "./src/components/core/DataCubeExecutionErrorAlert.tsx",
108
110
  "./src/components/core/DataCubeFormUtils.tsx",
109
111
  "./src/components/core/DataCubeLayout.tsx",
110
112
  "./src/components/core/DataCubePureCodeEditorUtils.tsx",
@@ -113,6 +115,7 @@
113
115
  "./src/components/view/editor/DataCubeEditorColumnPropertiesPanel.tsx",
114
116
  "./src/components/view/editor/DataCubeEditorColumnSelector.tsx",
115
117
  "./src/components/view/editor/DataCubeEditorColumnsPanel.tsx",
118
+ "./src/components/view/editor/DataCubeEditorDimensionsPanel.tsx",
116
119
  "./src/components/view/editor/DataCubeEditorGeneralPropertiesPanel.tsx",
117
120
  "./src/components/view/editor/DataCubeEditorHorizontalPivotsPanel.tsx",
118
121
  "./src/components/view/editor/DataCubeEditorSortsPanel.tsx",
@@ -121,6 +124,7 @@
121
124
  "./src/components/view/filter/DataCubeFilterEditor.tsx",
122
125
  "./src/components/view/grid/DataCubeGrid.tsx",
123
126
  "./src/components/view/grid/DataCubeGridShared.tsx",
127
+ "./src/components/view/grid/DataCubeMultidimensionalGrid.tsx",
124
128
  "./src/stores/DataCubeState.tsx",
125
129
  "./src/stores/core/DataCubeEngine.tsx",
126
130
  "./src/stores/core/aggregation/DataCubeQueryAggregateOperation__Average.tsx",