@finos/legend-application-repl 0.0.28 → 0.0.30
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/grammar/datacube_filter__lexer.g4 +40 -0
- package/grammar/datacube_filter__parser.g4 +14 -0
- package/grammar/generateGrammar.js +43 -0
- package/grammar/parser/generated/datacube_filter__lexer.interp +59 -0
- package/grammar/parser/generated/datacube_filter__lexer.tokens +14 -0
- package/grammar/parser/generated/datacube_filter__lexer.ts +142 -0
- package/grammar/parser/generated/datacube_filter__parser.interp +38 -0
- package/grammar/parser/generated/datacube_filter__parser.tokens +14 -0
- package/grammar/parser/generated/datacube_filter__parser.ts +514 -0
- package/grammar/parser/parser.ts +55 -0
- package/lib/components/Core_LegendREPLApplicationPlugin.d.ts.map +1 -1
- package/lib/components/Core_LegendREPLApplicationPlugin.js +0 -7
- package/lib/components/Core_LegendREPLApplicationPlugin.js.map +1 -1
- package/lib/components/LegendREPLApplication.d.ts +0 -1
- package/lib/components/LegendREPLApplication.d.ts.map +1 -1
- package/lib/components/LegendREPLFrameworkProvider.d.ts +0 -1
- package/lib/components/LegendREPLFrameworkProvider.d.ts.map +1 -1
- package/lib/components/REPLStoreProvider.d.ts +1 -1
- package/lib/components/REPLStoreProvider.d.ts.map +1 -1
- package/lib/components/REPLStoreProvider.js +1 -1
- package/lib/components/REPLStoreProvider.js.map +1 -1
- package/lib/components/dataCube/DataCube.d.ts.map +1 -1
- package/lib/components/dataCube/DataCube.js +15 -4
- package/lib/components/dataCube/DataCube.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditor.d.ts +2 -4
- package/lib/components/dataCube/editor/DataCubeEditor.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditor.js +109 -32
- package/lib/components/dataCube/editor/DataCubeEditor.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.d.ts +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js +178 -104
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js.map +1 -1
- package/lib/components/dataCube/editor/{DataCubeEditorSortPanel.d.ts → DataCubeEditorColumnPropertiesPanel.d.ts} +2 -5
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js +27 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js +27 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts +22 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js +230 -0
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.js +27 -0
- package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.js +27 -0
- package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js +27 -0
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.js +27 -0
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js +26 -0
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.js +27 -0
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.js.map +1 -0
- package/lib/components/dataCube/grid/DataCubeGrid.d.ts +1 -4
- package/lib/components/dataCube/grid/DataCubeGrid.d.ts.map +1 -1
- package/lib/components/dataCube/grid/DataCubeGrid.js +75 -30
- package/lib/components/dataCube/grid/DataCubeGrid.js.map +1 -1
- package/lib/grammar/generated/datacube_filter__lexer.d.ts +31 -0
- package/lib/grammar/generated/datacube_filter__lexer.js +118 -0
- package/lib/grammar/generated/datacube_filter__parser.d.ts +91 -0
- package/lib/grammar/generated/datacube_filter__parser.js +485 -0
- package/lib/grammar/parser.d.ts +16 -0
- package/lib/grammar/parser.js +39 -0
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +9 -6
- package/lib/server/REPLServerClient.d.ts +2 -3
- package/lib/server/REPLServerClient.d.ts.map +1 -1
- package/lib/server/models/DataCubeEngineModels.d.ts +8 -1
- package/lib/server/models/DataCubeEngineModels.d.ts.map +1 -1
- package/lib/server/models/DataCubeEngineModels.js +13 -0
- package/lib/server/models/DataCubeEngineModels.js.map +1 -1
- package/lib/stores/dataCube/DataCubeDefaultConfig.d.ts +17 -0
- package/lib/stores/dataCube/DataCubeDefaultConfig.d.ts.map +1 -0
- package/lib/stores/dataCube/DataCubeDefaultConfig.js +17 -0
- package/lib/stores/dataCube/DataCubeDefaultConfig.js.map +1 -0
- package/lib/stores/dataCube/DataCubeState.d.ts +6 -6
- package/lib/stores/dataCube/DataCubeState.d.ts.map +1 -1
- package/lib/stores/dataCube/DataCubeState.js +18 -14
- package/lib/stores/dataCube/DataCubeState.js.map +1 -1
- package/lib/stores/dataCube/{DataCubeStore.d.ts → REPLStore.d.ts} +1 -1
- package/lib/stores/dataCube/REPLStore.d.ts.map +1 -0
- package/lib/stores/dataCube/{DataCubeStore.js → REPLStore.js} +1 -1
- package/lib/stores/dataCube/REPLStore.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeCoreState.d.ts +29 -0
- package/lib/stores/dataCube/core/DataCubeCoreState.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeCoreState.js +46 -0
- package/lib/stores/dataCube/core/DataCubeCoreState.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeEngine.d.ts +2 -3
- package/lib/stores/dataCube/core/DataCubeEngine.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeEngine.js +2 -3
- package/lib/stores/dataCube/core/DataCubeEngine.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts +27 -3
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +210 -278
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts +72 -0
- package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQueryEngine.js +67 -0
- package/lib/stores/dataCube/core/DataCubeQueryEngine.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +73 -38
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js +101 -40
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts +32 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js +232 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.d.ts +8 -2
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.js +20 -5
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts +8 -3
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js +8 -4
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js.map +1 -1
- package/lib/stores/dataCube/editor/{DataCubeEditorCodeState.d.ts → DataCubeEditorCodePanelState.d.ts} +6 -5
- package/lib/stores/dataCube/editor/DataCubeEditorCodePanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/{DataCubeEditorCodeState.js → DataCubeEditorCodePanelState.js} +7 -7
- package/lib/stores/dataCube/editor/DataCubeEditorCodePanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts +30 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js +51 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts +29 -0
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js +63 -0
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/{DataCubeEditorQuerySnapshotBuilder.d.ts → DataCubeEditorPanelState.d.ts} +2 -2
- package/lib/stores/dataCube/editor/DataCubeEditorPanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/{DataCubeEditorQuerySnapshotBuilder.js → DataCubeEditorPanelState.js} +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorPanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts +34 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js +67 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts +10 -7
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorState.js +25 -17
- package/lib/stores/dataCube/editor/DataCubeEditorState.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts +13 -7
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +87 -86
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts +20 -0
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js +103 -0
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts +7 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js +121 -214
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts +25 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js +83 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts +6 -5
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridState.js +32 -10
- package/lib/stores/dataCube/grid/DataCubeGridState.js.map +1 -1
- package/package.json +15 -12
- package/src/components/Core_LegendREPLApplicationPlugin.tsx +0 -7
- package/src/components/REPLStoreProvider.tsx +1 -1
- package/src/components/dataCube/DataCube.tsx +51 -29
- package/src/components/dataCube/editor/DataCubeEditor.tsx +204 -95
- package/src/components/dataCube/editor/DataCubeEditorCodePanel.tsx +186 -190
- package/src/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.tsx +42 -0
- package/src/components/dataCube/editor/DataCubeEditorColumnsPanel.tsx +41 -0
- package/src/components/dataCube/editor/DataCubeEditorColumnsSelector.tsx +408 -0
- package/src/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.tsx +41 -0
- package/src/components/dataCube/editor/DataCubeEditorFilterPanel.tsx +41 -0
- package/src/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.tsx +48 -0
- package/src/components/dataCube/editor/DataCubeEditorHPivotsPanel.tsx +41 -0
- package/src/components/dataCube/editor/DataCubeEditorSortsPanel.tsx +41 -0
- package/src/components/dataCube/editor/DataCubeEditorVPivotsPanel.tsx +41 -0
- package/src/components/dataCube/grid/DataCubeGrid.tsx +134 -43
- package/src/server/REPLServerClient.ts +2 -2
- package/src/server/models/DataCubeEngineModels.ts +23 -1
- package/{lib/grid.css → src/stores/dataCube/DataCubeDefaultConfig.ts} +2 -2
- package/src/stores/dataCube/DataCubeState.ts +26 -20
- package/src/stores/dataCube/core/DataCubeCoreState.ts +57 -0
- package/src/stores/dataCube/core/DataCubeEngine.ts +6 -4
- package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +349 -353
- package/src/stores/dataCube/core/DataCubeQueryEngine.ts +90 -0
- package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +168 -156
- package/src/stores/dataCube/core/DataCubeQuerySnapshotBuilder.ts +398 -0
- package/src/stores/dataCube/core/DataCubeQuerySnapshotManager.ts +37 -5
- package/src/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.ts +13 -5
- package/src/stores/dataCube/editor/{DataCubeEditorCodeState.ts → DataCubeEditorCodePanelState.ts} +6 -6
- package/src/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.ts +61 -0
- package/src/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.ts +80 -0
- package/src/stores/dataCube/editor/{DataCubeEditorQuerySnapshotBuilder.ts → DataCubeEditorPanelState.ts} +1 -1
- package/src/stores/dataCube/editor/DataCubeEditorSortsPanelState.ts +116 -0
- package/src/stores/dataCube/editor/DataCubeEditorState.ts +29 -20
- package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +96 -128
- package/src/stores/dataCube/grid/DataCubeGridQueryBuilder.ts +154 -0
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.tsx +191 -0
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.ts +127 -0
- package/src/stores/dataCube/grid/DataCubeGridState.ts +41 -14
- package/tsconfig.json +23 -9
- package/lib/components/dataCube/editor/DataCubeEditorSortPanel.d.ts.map +0 -1
- package/lib/components/dataCube/editor/DataCubeEditorSortPanel.js +0 -61
- package/lib/components/dataCube/editor/DataCubeEditorSortPanel.js.map +0 -1
- package/lib/grid.css.map +0 -1
- package/lib/repl.css +0 -17
- package/lib/repl.css.map +0 -1
- package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts +0 -63
- package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubeMetaModelConst.js +0 -72
- package/lib/stores/dataCube/DataCubeMetaModelConst.js.map +0 -1
- package/lib/stores/dataCube/DataCubeStore.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubeStore.js.map +0 -1
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.d.ts +0 -37
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.d.ts.map +0 -1
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.js +0 -269
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.js.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorCodeState.d.ts.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorCodeState.js.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.d.ts.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.js.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.d.ts +0 -46
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.d.ts.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.js +0 -133
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.js.map +0 -1
- package/src/components/dataCube/editor/DataCubeEditorSortPanel.tsx +0 -274
- package/src/stores/dataCube/DataCubeMetaModelConst.ts +0 -76
- package/src/stores/dataCube/core/DataCubeQueryAnalyzer.ts +0 -424
- package/src/stores/dataCube/editor/DataCubeEditorSortState.ts +0 -198
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.ts +0 -281
- /package/src/stores/dataCube/{DataCubeStore.ts → REPLStore.ts} +0 -0
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/***************************************************************************************
|
|
18
|
+
* [CORE]
|
|
19
|
+
*
|
|
20
|
+
* These are utilities used to build the executable query from the query snapshot.
|
|
21
|
+
* The executable query is then used to fetch data.
|
|
22
|
+
***************************************************************************************/
|
|
23
|
+
|
|
17
24
|
import {
|
|
18
25
|
PRIMITIVE_TYPE,
|
|
19
26
|
V1_AppliedFunction,
|
|
@@ -37,13 +44,19 @@ import {
|
|
|
37
44
|
type V1_PrimitiveValueSpecification,
|
|
38
45
|
V1_Variable,
|
|
39
46
|
V1_deserializeValueSpecification,
|
|
40
|
-
extractElementNameFromPath,
|
|
47
|
+
extractElementNameFromPath as _name,
|
|
41
48
|
type V1_ValueSpecification,
|
|
42
49
|
} from '@finos/legend-graph';
|
|
43
|
-
import
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
DataCubeQuerySnapshot,
|
|
50
|
+
import {
|
|
51
|
+
type DataCubeQuerySnapshotFilterCondition,
|
|
52
|
+
type DataCubeQuerySnapshotFilter,
|
|
53
|
+
type DataCubeQuerySnapshot,
|
|
54
|
+
DataCubeQuerySnapshotSortDirection,
|
|
55
|
+
DataCubeQuerySnapshotFilterOperation,
|
|
56
|
+
DataCubeQueryFilterGroupOperation,
|
|
57
|
+
_findCol,
|
|
58
|
+
type DataCubeQuerySnapshotColumn,
|
|
59
|
+
type DataCubeQuerySnapshotAggregateColumn,
|
|
47
60
|
} from './DataCubeQuerySnapshot.js';
|
|
48
61
|
import {
|
|
49
62
|
guaranteeNonNullable,
|
|
@@ -51,405 +64,405 @@ import {
|
|
|
51
64
|
guaranteeIsBoolean,
|
|
52
65
|
guaranteeIsNumber,
|
|
53
66
|
UnsupportedOperationError,
|
|
67
|
+
guaranteeType,
|
|
68
|
+
type PlainObject,
|
|
54
69
|
} from '@finos/legend-shared';
|
|
55
70
|
import {
|
|
56
|
-
|
|
57
|
-
DATA_CUBE_COLUMN_SORT_DIRECTION,
|
|
58
|
-
DATA_CUBE_FILTER_OPERATION,
|
|
59
|
-
DATA_CUBE_FUNCTIONS,
|
|
71
|
+
DataCubeFunction,
|
|
60
72
|
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
61
|
-
|
|
73
|
+
INTERNAL__FILLER_COUNT_AGG_COLUMN_NAME,
|
|
74
|
+
type DataCubeQueryFunctionMap,
|
|
75
|
+
} from './DataCubeQueryEngine.js';
|
|
62
76
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
function2?: V1_Lambda | undefined,
|
|
68
|
-
): V1_ClassInstance {
|
|
69
|
-
const instance = new V1_ClassInstance();
|
|
70
|
-
instance.type = V1_ClassInstanceType.COL_SPEC;
|
|
71
|
-
const colSpec = new V1_ColSpec();
|
|
72
|
-
colSpec.name = name;
|
|
73
|
-
colSpec.type = type;
|
|
74
|
-
colSpec.function1 = function1;
|
|
75
|
-
colSpec.function2 = function2;
|
|
76
|
-
instance.value = colSpec;
|
|
77
|
-
return instance;
|
|
77
|
+
// --------------------------------- UTILITIES ---------------------------------
|
|
78
|
+
|
|
79
|
+
function _deserializeToLambda(json: PlainObject<V1_Lambda>) {
|
|
80
|
+
return guaranteeType(V1_deserializeValueSpecification(json, []), V1_Lambda);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const colSpec = new V1_ColSpec();
|
|
88
|
-
const aggLambda = new V1_Lambda();
|
|
83
|
+
export function _var(name?: string | undefined) {
|
|
84
|
+
const variable = new V1_Variable();
|
|
85
|
+
variable.name = name ?? DEFAULT_LAMBDA_VARIABLE_NAME;
|
|
86
|
+
return variable;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function _property(name: string, variable?: V1_Variable | undefined) {
|
|
89
90
|
const property = new V1_AppliedProperty();
|
|
90
|
-
property.property =
|
|
91
|
-
property.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
91
|
+
property.property = name;
|
|
92
|
+
property.parameters.push(variable ?? _var());
|
|
93
|
+
return property;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function _lambda(
|
|
97
|
+
parameters: V1_Variable[],
|
|
98
|
+
body: V1_ValueSpecification[],
|
|
99
|
+
) {
|
|
100
|
+
const lambda = new V1_Lambda();
|
|
101
|
+
lambda.parameters = parameters;
|
|
102
|
+
lambda.body = body;
|
|
103
|
+
return lambda;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function _function(
|
|
107
|
+
functionName: string,
|
|
108
|
+
parameters: V1_ValueSpecification[],
|
|
109
|
+
) {
|
|
110
|
+
const func = new V1_AppliedFunction();
|
|
111
|
+
func.function = functionName;
|
|
112
|
+
func.parameters = parameters;
|
|
113
|
+
return func;
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
function
|
|
116
|
+
function _collection(values: V1_ValueSpecification[]) {
|
|
117
|
+
const collection = new V1_Collection();
|
|
118
|
+
collection.multiplicity = new V1_Multiplicity(values.length, values.length);
|
|
119
|
+
collection.values = values;
|
|
120
|
+
return collection;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function _value(
|
|
114
124
|
type: string,
|
|
115
|
-
|
|
125
|
+
value: unknown,
|
|
116
126
|
): V1_PrimitiveValueSpecification {
|
|
127
|
+
const _val = <T extends V1_PrimitiveValueSpecification & { value: unknown }>(
|
|
128
|
+
primitiveValue: T,
|
|
129
|
+
val: unknown,
|
|
130
|
+
): T => {
|
|
131
|
+
primitiveValue.value = val;
|
|
132
|
+
return primitiveValue;
|
|
133
|
+
};
|
|
117
134
|
switch (type) {
|
|
118
|
-
case PRIMITIVE_TYPE.STRING:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
case PRIMITIVE_TYPE.BOOLEAN: {
|
|
124
|
-
const booleanValue = new V1_CBoolean();
|
|
125
|
-
booleanValue.value = guaranteeIsBoolean(column);
|
|
126
|
-
return booleanValue;
|
|
127
|
-
}
|
|
135
|
+
case PRIMITIVE_TYPE.STRING:
|
|
136
|
+
return _val(new V1_CString(), guaranteeIsString(value));
|
|
137
|
+
case PRIMITIVE_TYPE.BOOLEAN:
|
|
138
|
+
return _val(new V1_CBoolean(), guaranteeIsBoolean(value));
|
|
128
139
|
case PRIMITIVE_TYPE.NUMBER:
|
|
129
|
-
case PRIMITIVE_TYPE.DECIMAL:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const cInteger = new V1_CInteger();
|
|
136
|
-
cInteger.value = guaranteeIsNumber(column);
|
|
137
|
-
return cInteger;
|
|
138
|
-
}
|
|
139
|
-
case PRIMITIVE_TYPE.FLOAT: {
|
|
140
|
-
const cFloat = new V1_CFloat();
|
|
141
|
-
cFloat.value = guaranteeIsNumber(column);
|
|
142
|
-
return cFloat;
|
|
143
|
-
}
|
|
140
|
+
case PRIMITIVE_TYPE.DECIMAL:
|
|
141
|
+
return _val(new V1_CDecimal(), guaranteeIsNumber(value));
|
|
142
|
+
case PRIMITIVE_TYPE.INTEGER:
|
|
143
|
+
return _val(new V1_CInteger(), guaranteeIsNumber(value));
|
|
144
|
+
case PRIMITIVE_TYPE.FLOAT:
|
|
145
|
+
return _val(new V1_CFloat(), guaranteeIsNumber(value));
|
|
144
146
|
case PRIMITIVE_TYPE.DATE:
|
|
145
|
-
case PRIMITIVE_TYPE.DATETIME:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const cStrictDate = new V1_CStrictDate();
|
|
152
|
-
cStrictDate.value = guaranteeIsString(column);
|
|
153
|
-
return cStrictDate;
|
|
154
|
-
}
|
|
155
|
-
case PRIMITIVE_TYPE.STRICTTIME: {
|
|
156
|
-
const cStrictTime = new V1_CStrictTime();
|
|
157
|
-
cStrictTime.value = guaranteeIsString(column);
|
|
158
|
-
return cStrictTime;
|
|
159
|
-
}
|
|
147
|
+
case PRIMITIVE_TYPE.DATETIME:
|
|
148
|
+
return _val(new V1_CDateTime(), guaranteeIsString(value));
|
|
149
|
+
case PRIMITIVE_TYPE.STRICTDATE:
|
|
150
|
+
return _val(new V1_CStrictDate(), guaranteeIsString(value));
|
|
151
|
+
case PRIMITIVE_TYPE.STRICTTIME:
|
|
152
|
+
return _val(new V1_CStrictTime(), guaranteeIsString(value));
|
|
160
153
|
default:
|
|
161
|
-
throw new UnsupportedOperationError(
|
|
162
|
-
`Unsupported dataCube column type ${type}`,
|
|
163
|
-
);
|
|
154
|
+
throw new UnsupportedOperationError(`Unsupported column type '${type}'`);
|
|
164
155
|
}
|
|
165
156
|
}
|
|
166
157
|
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
let conditionExpressions: V1_ValueSpecification[] = [];
|
|
173
|
-
groupFilter.conditions.forEach((condition) => {
|
|
174
|
-
const conditionExpression = processFilterQuery(condition);
|
|
175
|
-
conditionExpressions.push(conditionExpression);
|
|
176
|
-
if (conditionExpressions.length === 2) {
|
|
177
|
-
const groupCondition = groupFilter.groupOperation;
|
|
178
|
-
const groupFunc = new V1_AppliedFunction();
|
|
179
|
-
groupFunc.function = groupCondition;
|
|
180
|
-
groupFunc.parameters = conditionExpressions;
|
|
181
|
-
conditionExpressions = [groupFunc];
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
if (conditionExpressions.length === 1) {
|
|
185
|
-
return guaranteeNonNullable(conditionExpressions[0]);
|
|
186
|
-
}
|
|
187
|
-
} else {
|
|
188
|
-
const condition = filter as DataCubeQueryFilterCondition;
|
|
189
|
-
const filterCondition = new V1_AppliedFunction();
|
|
190
|
-
const property = new V1_AppliedProperty();
|
|
191
|
-
property.property = condition.name;
|
|
192
|
-
property.class = condition.type;
|
|
193
|
-
property.parameters = [defaultVariable];
|
|
158
|
+
function _elementPtr(fullPath: string) {
|
|
159
|
+
const ptr = new V1_PackageableElementPtr();
|
|
160
|
+
ptr.fullPath = fullPath;
|
|
161
|
+
return ptr;
|
|
162
|
+
}
|
|
194
163
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
case DATA_CUBE_FILTER_OPERATION.CONTAINS:
|
|
202
|
-
case DATA_CUBE_FILTER_OPERATION.ENDS_WITH:
|
|
203
|
-
case DATA_CUBE_FILTER_OPERATION.STARTS_WITH: {
|
|
204
|
-
filterCondition.function = condition.operation;
|
|
205
|
-
filterCondition.parameters.push(property);
|
|
206
|
-
filterCondition.parameters.push(
|
|
207
|
-
getPrimitiveValueSpecification(condition.type, condition.value),
|
|
208
|
-
);
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
case DATA_CUBE_FILTER_OPERATION.BLANK: {
|
|
212
|
-
filterCondition.function = condition.operation;
|
|
213
|
-
filterCondition.parameters.push(property);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
case DATA_CUBE_FILTER_OPERATION.NOT_EQUAL: {
|
|
217
|
-
filterCondition.function = extractElementNameFromPath(
|
|
218
|
-
DATA_CUBE_FUNCTIONS.NOT,
|
|
219
|
-
);
|
|
164
|
+
function _classInstance(type: string, value: unknown) {
|
|
165
|
+
const instance = new V1_ClassInstance();
|
|
166
|
+
instance.type = type;
|
|
167
|
+
instance.value = value;
|
|
168
|
+
return instance;
|
|
169
|
+
}
|
|
220
170
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
171
|
+
export function _colSpec(
|
|
172
|
+
name: string,
|
|
173
|
+
function1?: V1_Lambda | undefined,
|
|
174
|
+
function2?: V1_Lambda | undefined,
|
|
175
|
+
) {
|
|
176
|
+
const colSpec = new V1_ColSpec();
|
|
177
|
+
colSpec.name = name;
|
|
178
|
+
colSpec.function1 = function1;
|
|
179
|
+
colSpec.function2 = function2;
|
|
180
|
+
return colSpec;
|
|
181
|
+
}
|
|
227
182
|
|
|
228
|
-
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
case DATA_CUBE_FILTER_OPERATION.NOT_BLANK: {
|
|
232
|
-
filterCondition.function = extractElementNameFromPath(
|
|
233
|
-
DATA_CUBE_FUNCTIONS.NOT,
|
|
234
|
-
);
|
|
183
|
+
// --------------------------------- BUILDING BLOCKS ---------------------------------
|
|
235
184
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
185
|
+
export function _col(
|
|
186
|
+
name: string,
|
|
187
|
+
function1?: V1_Lambda | undefined,
|
|
188
|
+
function2?: V1_Lambda | undefined,
|
|
189
|
+
) {
|
|
190
|
+
return _classInstance(
|
|
191
|
+
V1_ClassInstanceType.COL_SPEC,
|
|
192
|
+
_colSpec(name, function1, function2),
|
|
193
|
+
);
|
|
194
|
+
}
|
|
242
195
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
DATA_CUBE_FUNCTIONS.NOT,
|
|
249
|
-
);
|
|
196
|
+
export function _cols(colSpecs: V1_ColSpec[]) {
|
|
197
|
+
const colSpecArray = new V1_ColSpecArray();
|
|
198
|
+
colSpecArray.colSpecs = colSpecs;
|
|
199
|
+
return _classInstance(V1_ClassInstanceType.COL_SPEC_ARRAY, colSpecArray);
|
|
200
|
+
}
|
|
250
201
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
202
|
+
export function _aggCols(
|
|
203
|
+
columns: DataCubeQuerySnapshotAggregateColumn[],
|
|
204
|
+
): V1_ColSpec[] {
|
|
205
|
+
const variable = _var();
|
|
206
|
+
return columns.length
|
|
207
|
+
? columns.map((agg) =>
|
|
208
|
+
_colSpec(
|
|
209
|
+
agg.name,
|
|
210
|
+
_lambda([variable], [_property(agg.name, variable)]),
|
|
211
|
+
_lambda([variable], [_function(agg.function, [variable])]),
|
|
212
|
+
),
|
|
213
|
+
)
|
|
214
|
+
: // if no aggregates are specified, add a dummy count() aggregate to satisfy compiler
|
|
215
|
+
[
|
|
216
|
+
_colSpec(
|
|
217
|
+
INTERNAL__FILLER_COUNT_AGG_COLUMN_NAME,
|
|
218
|
+
_lambda([variable], [variable]),
|
|
219
|
+
_lambda([variable], [_function(DataCubeFunction.COUNT, [variable])]),
|
|
220
|
+
),
|
|
221
|
+
];
|
|
222
|
+
}
|
|
257
223
|
|
|
258
|
-
|
|
259
|
-
|
|
224
|
+
export function _filter(
|
|
225
|
+
filter: DataCubeQuerySnapshotFilter | DataCubeQuerySnapshotFilterCondition,
|
|
226
|
+
): V1_ValueSpecification {
|
|
227
|
+
if ('groupOperation' in filter) {
|
|
228
|
+
const group = filter;
|
|
229
|
+
const groupOperation =
|
|
230
|
+
group.groupOperation === DataCubeQueryFilterGroupOperation.AND
|
|
231
|
+
? DataCubeFunction.AND
|
|
232
|
+
: DataCubeFunction.OR;
|
|
233
|
+
let conditions: V1_ValueSpecification[] = [];
|
|
234
|
+
group.conditions.forEach((condition) => {
|
|
235
|
+
conditions.push(_filter(condition));
|
|
236
|
+
// NOTE: a group operation (and/or) function can only have 2 parameters, so we
|
|
237
|
+
// have to breakdown the group operation into nested group functions
|
|
238
|
+
if (conditions.length === 2) {
|
|
239
|
+
conditions = [_function(groupOperation, conditions)];
|
|
260
240
|
}
|
|
241
|
+
});
|
|
242
|
+
return guaranteeNonNullable(conditions[0]);
|
|
243
|
+
} else {
|
|
244
|
+
const condition = filter;
|
|
245
|
+
const property = _property(condition.name);
|
|
246
|
+
const _cond = (fn: string, ...p: V1_ValueSpecification[]) =>
|
|
247
|
+
_function(_name(fn), [property, ...p]);
|
|
248
|
+
const _val = () => _value(condition.type, condition.value);
|
|
249
|
+
const _not = (fn: V1_AppliedFunction) =>
|
|
250
|
+
_function(_name(DataCubeFunction.NOT), [fn]);
|
|
251
|
+
switch (condition.operation) {
|
|
252
|
+
case DataCubeQuerySnapshotFilterOperation.EQUAL:
|
|
253
|
+
return _cond(DataCubeFunction.EQUAL, _val());
|
|
254
|
+
case DataCubeQuerySnapshotFilterOperation.GREATER_THAN:
|
|
255
|
+
return _cond(DataCubeFunction.GREATER_THAN, _val());
|
|
256
|
+
case DataCubeQuerySnapshotFilterOperation.GREATER_THAN_OR_EQUAL:
|
|
257
|
+
return _cond(DataCubeFunction.GREATER_THAN_EQUAL, _val());
|
|
258
|
+
case DataCubeQuerySnapshotFilterOperation.LESS_THAN:
|
|
259
|
+
return _cond(DataCubeFunction.LESS_THAN, _val());
|
|
260
|
+
case DataCubeQuerySnapshotFilterOperation.LESS_THAN_OR_EQUAL:
|
|
261
|
+
return _cond(DataCubeFunction.LESS_THAN_EQUAL, _val());
|
|
262
|
+
case DataCubeQuerySnapshotFilterOperation.CONTAINS:
|
|
263
|
+
return _cond(DataCubeFunction.CONTAINS, _val());
|
|
264
|
+
case DataCubeQuerySnapshotFilterOperation.ENDS_WITH:
|
|
265
|
+
return _cond(DataCubeFunction.ENDS_WITH, _val());
|
|
266
|
+
case DataCubeQuerySnapshotFilterOperation.STARTS_WITH:
|
|
267
|
+
return _cond(DataCubeFunction.STARTS_WITH, _val());
|
|
268
|
+
case DataCubeQuerySnapshotFilterOperation.BLANK:
|
|
269
|
+
return _cond(DataCubeFunction.IS_EMPTY);
|
|
270
|
+
case DataCubeQuerySnapshotFilterOperation.NOT_EQUAL:
|
|
271
|
+
return _not(_cond(DataCubeFunction.EQUAL, _val()));
|
|
272
|
+
case DataCubeQuerySnapshotFilterOperation.NOT_BLANK:
|
|
273
|
+
return _not(_cond(DataCubeFunction.IS_EMPTY));
|
|
274
|
+
case DataCubeQuerySnapshotFilterOperation.NOT_CONTAINS:
|
|
275
|
+
return _not(_cond(DataCubeFunction.CONTAINS, _val()));
|
|
261
276
|
default:
|
|
262
277
|
throw new UnsupportedOperationError(
|
|
263
|
-
`Unsupported filter operation ${condition.operation}`,
|
|
278
|
+
`Unsupported filter operation '${condition.operation}'`,
|
|
264
279
|
);
|
|
265
280
|
}
|
|
266
|
-
return filterCondition;
|
|
267
281
|
}
|
|
268
|
-
throw new UnsupportedOperationError(`Unsupported dataCube filter`, filter);
|
|
269
282
|
}
|
|
270
283
|
|
|
271
|
-
export function
|
|
284
|
+
export function _groupByExtend(
|
|
285
|
+
columns: DataCubeQuerySnapshotColumn[],
|
|
286
|
+
columnsUsedInGroupBy: DataCubeQuerySnapshotColumn[],
|
|
287
|
+
) {
|
|
288
|
+
const missingCols = columns.filter(
|
|
289
|
+
(col) => !_findCol(columnsUsedInGroupBy, col.name),
|
|
290
|
+
);
|
|
291
|
+
return missingCols.length
|
|
292
|
+
? _function(_name(DataCubeFunction.EXTEND), [
|
|
293
|
+
_cols(
|
|
294
|
+
missingCols.map((col) =>
|
|
295
|
+
_colSpec(
|
|
296
|
+
col.name,
|
|
297
|
+
_lambda([_var()], [_value(PRIMITIVE_TYPE.STRING, '')]),
|
|
298
|
+
),
|
|
299
|
+
),
|
|
300
|
+
),
|
|
301
|
+
])
|
|
302
|
+
: undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// --------------------------------- MAIN ---------------------------------
|
|
306
|
+
|
|
307
|
+
export function buildExecutableQuery(
|
|
272
308
|
snapshot: DataCubeQuerySnapshot,
|
|
309
|
+
options?: {
|
|
310
|
+
postProcessor?: (
|
|
311
|
+
snapshot: DataCubeQuerySnapshot,
|
|
312
|
+
sequence: V1_AppliedFunction[],
|
|
313
|
+
funcMap: DataCubeQueryFunctionMap,
|
|
314
|
+
) => void;
|
|
315
|
+
pagination?:
|
|
316
|
+
| {
|
|
317
|
+
start: number;
|
|
318
|
+
end: number;
|
|
319
|
+
}
|
|
320
|
+
| undefined;
|
|
321
|
+
},
|
|
273
322
|
): V1_ValueSpecification {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
[],
|
|
277
|
-
);
|
|
323
|
+
const data = snapshot.data;
|
|
324
|
+
const sourceQuery = V1_deserializeValueSpecification(data.sourceQuery, []);
|
|
278
325
|
const sequence: V1_AppliedFunction[] = [];
|
|
326
|
+
const funcMap: DataCubeQueryFunctionMap = {};
|
|
327
|
+
const _process = (
|
|
328
|
+
funcMapKey: keyof DataCubeQueryFunctionMap,
|
|
329
|
+
func: V1_AppliedFunction,
|
|
330
|
+
) => {
|
|
331
|
+
sequence.push(func);
|
|
332
|
+
funcMap[funcMapKey] = func;
|
|
333
|
+
};
|
|
279
334
|
|
|
280
335
|
// --------------------------------- LEAF EXTEND ---------------------------------
|
|
281
|
-
// TODO: @akphi - implement this
|
|
282
336
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
filterLambda.body = [filterValueSpec];
|
|
294
|
-
|
|
295
|
-
filterLambda.parameters = [defaultVariable];
|
|
296
|
-
const filterFunc = new V1_AppliedFunction();
|
|
297
|
-
filterFunc.function = extractElementNameFromPath(
|
|
298
|
-
DATA_CUBE_FUNCTIONS.FILTER,
|
|
337
|
+
if (data.leafExtendedColumns.length) {
|
|
338
|
+
_process(
|
|
339
|
+
'leafExtend',
|
|
340
|
+
_function(_name(DataCubeFunction.EXTEND), [
|
|
341
|
+
_cols(
|
|
342
|
+
data.leafExtendedColumns.map((col) =>
|
|
343
|
+
_colSpec(col.name, _deserializeToLambda(col.lambda)),
|
|
344
|
+
),
|
|
345
|
+
),
|
|
346
|
+
]),
|
|
299
347
|
);
|
|
300
|
-
filterFunc.parameters.push(filterLambda);
|
|
301
|
-
sequence.push(filterFunc);
|
|
302
348
|
}
|
|
303
349
|
|
|
304
|
-
// ---------------------------------
|
|
305
|
-
// TODO: @akphi - implement this
|
|
350
|
+
// --------------------------------- FILTER ---------------------------------
|
|
306
351
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
aggregationInstance.type = V1_ClassInstanceType.COL_SPEC_ARRAY;
|
|
316
|
-
|
|
317
|
-
if (
|
|
318
|
-
snapshot.groupByExpandedKeys.length !== snapshot.groupByColumns.length
|
|
319
|
-
) {
|
|
320
|
-
const groupKeys = snapshot.groupByExpandedKeys;
|
|
321
|
-
for (let index = 0; index <= groupKeys.length; index++) {
|
|
322
|
-
const currentGroupByColumn = snapshot.groupByColumns[index];
|
|
323
|
-
const columnSpec = new V1_ColSpec();
|
|
324
|
-
columnSpec.name = guaranteeNonNullable(currentGroupByColumn).name;
|
|
325
|
-
groupByColSpecArray.colSpecs.push(columnSpec);
|
|
326
|
-
}
|
|
352
|
+
if (data.filter) {
|
|
353
|
+
_process(
|
|
354
|
+
'filter',
|
|
355
|
+
_function(_name(DataCubeFunction.FILTER), [
|
|
356
|
+
_lambda([_var()], [_filter(data.filter)]),
|
|
357
|
+
]),
|
|
358
|
+
);
|
|
359
|
+
}
|
|
327
360
|
|
|
328
|
-
|
|
329
|
-
if (snapshot.groupByAggColumns.length === 0) {
|
|
330
|
-
const column = guaranteeNonNullable(snapshot.groupByColumns[0]);
|
|
331
|
-
const colSpec = getAggregationColSpec(
|
|
332
|
-
column.name,
|
|
333
|
-
DATA_CUBE_AGGREGATE_FUNCTION.COUNT,
|
|
334
|
-
PRIMITIVE_TYPE.STRING,
|
|
335
|
-
DATA_CUBE_AGGREGATE_FUNCTION.COUNT,
|
|
336
|
-
);
|
|
337
|
-
aggregationColSpecArray.colSpecs.push(colSpec);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
361
|
+
// --------------------------------- GROUP BY ---------------------------------
|
|
340
362
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
363
|
+
if (data.groupBy) {
|
|
364
|
+
const groupBy = data.groupBy;
|
|
365
|
+
_process(
|
|
366
|
+
'groupBy',
|
|
367
|
+
_function(_name(DataCubeFunction.GROUP_BY), [
|
|
368
|
+
_cols(groupBy.columns.map((col) => _colSpec(col.name))),
|
|
369
|
+
_cols(_aggCols(groupBy.aggColumns)),
|
|
370
|
+
]),
|
|
371
|
+
);
|
|
350
372
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const groupBy = new V1_AppliedFunction();
|
|
359
|
-
groupBy.function = extractElementNameFromPath(
|
|
360
|
-
DATA_CUBE_FUNCTIONS.GROUP_BY,
|
|
361
|
-
);
|
|
362
|
-
groupBy.parameters = [groupByInstance, aggregationInstance];
|
|
363
|
-
sequence.push(groupBy);
|
|
373
|
+
// extend columns to maintain the same set of columns prior to groupBy()
|
|
374
|
+
const groupByExtend = _groupByExtend(snapshot.stageCols('aggregation'), [
|
|
375
|
+
...groupBy.columns,
|
|
376
|
+
...groupBy.aggColumns,
|
|
377
|
+
]);
|
|
378
|
+
if (groupByExtend) {
|
|
379
|
+
_process('groupByExtend', groupByExtend);
|
|
364
380
|
}
|
|
365
381
|
}
|
|
366
382
|
|
|
367
|
-
// --------------------------------- SELECT ---------------------------------
|
|
368
|
-
// TODO: @akphi - implement this
|
|
369
|
-
|
|
370
383
|
// --------------------------------- PIVOT ---------------------------------
|
|
371
|
-
// TODO: @akphi - implement this
|
|
372
|
-
|
|
373
|
-
// --------------------------------- CAST ---------------------------------
|
|
374
|
-
// TODO: @akphi - implement this
|
|
384
|
+
// TODO: @akphi - implement this and CAST
|
|
375
385
|
|
|
376
386
|
// --------------------------------- GROUP EXTEND ---------------------------------
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
387
|
+
|
|
388
|
+
if (data.groupExtendedColumns.length) {
|
|
389
|
+
_process(
|
|
390
|
+
'groupExtend',
|
|
391
|
+
_function(_name(DataCubeFunction.EXTEND), [
|
|
392
|
+
_cols(
|
|
393
|
+
data.groupExtendedColumns.map((col) =>
|
|
394
|
+
_colSpec(col.name, _deserializeToLambda(col.lambda)),
|
|
395
|
+
),
|
|
396
|
+
),
|
|
397
|
+
]),
|
|
381
398
|
);
|
|
382
|
-
|
|
383
|
-
classInstance.type = V1_ClassInstanceType.COL_SPEC_ARRAY;
|
|
384
|
-
const colSpecArray = new V1_ColSpecArray();
|
|
385
|
-
classInstance.value = colSpecArray;
|
|
386
|
-
snapshot.columns.forEach((col) => {
|
|
387
|
-
if (!snapshot.groupByColumns.find((c) => c.name === col.name)) {
|
|
388
|
-
const colSpec = new V1_ColSpec();
|
|
389
|
-
const lambda = new V1_Lambda();
|
|
390
|
-
const defaultVariable = new V1_Variable();
|
|
391
|
-
defaultVariable.name = DEFAULT_LAMBDA_VARIABLE_NAME;
|
|
392
|
-
lambda.parameters.push(defaultVariable);
|
|
393
|
-
const variableValue = new V1_CString();
|
|
394
|
-
variableValue.value = '';
|
|
395
|
-
lambda.body.push(variableValue);
|
|
396
|
-
colSpec.function1 = lambda;
|
|
397
|
-
colSpec.name = col.name;
|
|
398
|
-
colSpecArray.colSpecs.push(colSpec);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
extendFunc.parameters.push(classInstance);
|
|
399
|
+
}
|
|
402
400
|
|
|
403
|
-
|
|
401
|
+
// --------------------------------- SELECT ---------------------------------
|
|
402
|
+
|
|
403
|
+
if (data.selectColumns.length) {
|
|
404
|
+
_process(
|
|
405
|
+
'select',
|
|
406
|
+
_function(_name(DataCubeFunction.SELECT), [
|
|
407
|
+
_cols(data.selectColumns.map((col) => _colSpec(col.name))),
|
|
408
|
+
]),
|
|
409
|
+
);
|
|
404
410
|
}
|
|
405
411
|
|
|
406
412
|
// --------------------------------- SORT ---------------------------------
|
|
407
413
|
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
414
|
+
if (data.sortColumns.length) {
|
|
415
|
+
_process(
|
|
416
|
+
'sort',
|
|
417
|
+
_function(_name(DataCubeFunction.SORT), [
|
|
418
|
+
_collection(
|
|
419
|
+
data.sortColumns.map((col) =>
|
|
420
|
+
_function(
|
|
421
|
+
_name(
|
|
422
|
+
col.direction === DataCubeQuerySnapshotSortDirection.ASCENDING
|
|
423
|
+
? DataCubeFunction.ASC
|
|
424
|
+
: DataCubeFunction.DESC,
|
|
425
|
+
),
|
|
426
|
+
[_col(col.name)],
|
|
427
|
+
),
|
|
428
|
+
),
|
|
429
|
+
),
|
|
430
|
+
]),
|
|
415
431
|
);
|
|
416
|
-
snapshot.sortColumns.forEach((sortCol) => {
|
|
417
|
-
if (
|
|
418
|
-
snapshot.groupByColumns.length ===
|
|
419
|
-
snapshot.groupByExpandedKeys.length ||
|
|
420
|
-
snapshot.groupByColumns.map((col) => col.name).indexOf(sortCol.name) ===
|
|
421
|
-
snapshot.groupByExpandedKeys.length
|
|
422
|
-
) {
|
|
423
|
-
const sortInfo = new V1_AppliedFunction();
|
|
424
|
-
sortInfo.function = extractElementNameFromPath(
|
|
425
|
-
sortCol.direction === DATA_CUBE_COLUMN_SORT_DIRECTION.ASCENDING
|
|
426
|
-
? DATA_CUBE_FUNCTIONS.ASC
|
|
427
|
-
: DATA_CUBE_FUNCTIONS.DESC,
|
|
428
|
-
);
|
|
429
|
-
sortInfo.parameters.push(createColSpec(sortCol.name));
|
|
430
|
-
sortInfos.values.push(sortInfo);
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
sort.parameters.push(sortInfos);
|
|
434
|
-
if (sortInfos.values.length) {
|
|
435
|
-
sequence.push(sort);
|
|
436
|
-
}
|
|
437
432
|
}
|
|
438
433
|
|
|
439
434
|
// --------------------------------- LIMIT ---------------------------------
|
|
440
|
-
|
|
435
|
+
|
|
436
|
+
if (data.limit) {
|
|
437
|
+
_process(
|
|
438
|
+
'limit',
|
|
439
|
+
_function(_name(DataCubeFunction.LIMIT), [
|
|
440
|
+
_value(PRIMITIVE_TYPE.INTEGER, data.limit),
|
|
441
|
+
]),
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// --------------------------------- SLICE ---------------------------------
|
|
446
|
+
|
|
447
|
+
if (options?.pagination) {
|
|
448
|
+
sequence.push(
|
|
449
|
+
_function(_name(DataCubeFunction.SLICE), [
|
|
450
|
+
_value(PRIMITIVE_TYPE.INTEGER, options.pagination.start),
|
|
451
|
+
_value(PRIMITIVE_TYPE.INTEGER, options.pagination.end),
|
|
452
|
+
]),
|
|
453
|
+
);
|
|
454
|
+
}
|
|
441
455
|
|
|
442
456
|
// --------------------------------- FROM ---------------------------------
|
|
443
457
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
runtimePtr.fullPath = snapshot.runtime;
|
|
448
|
-
fromFunc.parameters.push(runtimePtr);
|
|
449
|
-
sequence.push(fromFunc);
|
|
458
|
+
sequence.push(
|
|
459
|
+
_function(_name(DataCubeFunction.FROM), [_elementPtr(data.runtime)]),
|
|
460
|
+
);
|
|
450
461
|
|
|
451
462
|
// --------------------------------- FINALIZE ---------------------------------
|
|
452
463
|
|
|
464
|
+
options?.postProcessor?.(snapshot, sequence, funcMap);
|
|
465
|
+
|
|
453
466
|
if (!sequence.length) {
|
|
454
467
|
return sourceQuery;
|
|
455
468
|
}
|
|
@@ -458,22 +471,5 @@ export function buildExecutableQueryFromSnapshot(
|
|
|
458
471
|
i === 0 ? sourceQuery : guaranteeNonNullable(sequence[i - 1]),
|
|
459
472
|
);
|
|
460
473
|
}
|
|
461
|
-
|
|
462
474
|
return guaranteeNonNullable(sequence[sequence.length - 1]);
|
|
463
475
|
}
|
|
464
|
-
|
|
465
|
-
// export async function buildPersistentQueryFromSnapshot(
|
|
466
|
-
// snapshot: DataCubeQuerySnapshot,
|
|
467
|
-
// ) {
|
|
468
|
-
// return new DataCubeQuery(
|
|
469
|
-
// snapshot.name,
|
|
470
|
-
// snapshot.sourceQuery,
|
|
471
|
-
// snapshot.configuration,
|
|
472
|
-
// );
|
|
473
|
-
// }
|
|
474
|
-
|
|
475
|
-
// name!: string;
|
|
476
|
-
// query!: string;
|
|
477
|
-
// partialQuery!: string;
|
|
478
|
-
// source!: DataCubeQuerySource;
|
|
479
|
-
// configuration!: DataCubeConfiguration;
|