@finos/legend-application-repl 0.0.21 → 0.0.23
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/{stores/CompletionResult.d.ts → __lib__/LegendREPLEvent.d.ts} +4 -6
- package/lib/__lib__/LegendREPLEvent.d.ts.map +1 -0
- package/lib/__lib__/LegendREPLEvent.js +21 -0
- package/lib/__lib__/LegendREPLEvent.js.map +1 -0
- package/lib/{stores/dataCube/DataCubePanelState.js → __lib__/LegendREPLSetting.d.ts} +3 -6
- package/lib/__lib__/LegendREPLSetting.d.ts.map +1 -0
- package/lib/{components/grid/TDSLambdaBuilder.d.ts → __lib__/LegendREPLSetting.js} +5 -4
- package/lib/__lib__/LegendREPLSetting.js.map +1 -0
- package/lib/application/{LegendREPLGridClient.d.ts → LegendREPL.d.ts} +10 -10
- package/lib/application/LegendREPL.d.ts.map +1 -0
- package/lib/application/{LegendREPLGridClient.js → LegendREPL.js} +10 -15
- package/lib/application/LegendREPL.js.map +1 -0
- package/lib/application/{LegendREPLGridClientApplicationConfig.d.ts → LegendREPLApplicationConfig.d.ts} +4 -4
- package/lib/application/LegendREPLApplicationConfig.d.ts.map +1 -0
- package/lib/application/{LegendREPLGridClientApplicationConfig.js → LegendREPLApplicationConfig.js} +2 -2
- package/lib/application/LegendREPLApplicationConfig.js.map +1 -0
- package/lib/application/{LegendREPLGridClientPluginManager.d.ts → LegendREPLPluginManager.d.ts} +4 -4
- package/lib/application/LegendREPLPluginManager.d.ts.map +1 -0
- package/lib/application/{LegendREPLGridClientPluginManager.js → LegendREPLPluginManager.js} +3 -3
- package/lib/application/LegendREPLPluginManager.js.map +1 -0
- package/lib/components/{Core_LegendREPLGridClientApplicationPlugin.d.ts → Core_LegendREPLApplicationPlugin.d.ts} +3 -3
- package/lib/components/Core_LegendREPLApplicationPlugin.d.ts.map +1 -0
- package/lib/components/{Core_LegendREPLGridClientApplicationPlugin.js → Core_LegendREPLApplicationPlugin.js} +12 -7
- package/lib/components/Core_LegendREPLApplicationPlugin.js.map +1 -0
- package/lib/components/{AgGrid.d.ts → LegendREPLApplication.d.ts} +8 -6
- package/lib/components/LegendREPLApplication.d.ts.map +1 -0
- package/lib/components/LegendREPLApplication.js +32 -0
- package/lib/components/LegendREPLApplication.js.map +1 -0
- package/lib/components/{LegendREPLGridClientFrameworkProvider.d.ts → LegendREPLFrameworkProvider.d.ts} +4 -4
- package/lib/components/LegendREPLFrameworkProvider.d.ts.map +1 -0
- package/lib/components/{LegendREPLGridClientFrameworkProvider.js → LegendREPLFrameworkProvider.js} +9 -9
- package/lib/components/LegendREPLFrameworkProvider.js.map +1 -0
- package/lib/components/{REPLGridClientStoreProvider.d.ts → REPLStoreProvider.d.ts} +5 -5
- package/lib/components/REPLStoreProvider.d.ts.map +1 -0
- package/lib/components/{REPLGridClientStoreProvider.js → REPLStoreProvider.js} +9 -9
- package/lib/components/REPLStoreProvider.js.map +1 -0
- package/lib/components/dataCube/DataCube.d.ts +19 -0
- package/lib/components/dataCube/DataCube.d.ts.map +1 -0
- package/lib/components/dataCube/DataCube.js +33 -0
- package/lib/components/dataCube/DataCube.js.map +1 -0
- package/lib/components/{REPLGridClient.d.ts → dataCube/editor/DataCubeEditor.d.ts} +5 -9
- package/lib/components/dataCube/editor/DataCubeEditor.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditor.js +54 -0
- package/lib/components/dataCube/editor/DataCubeEditor.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.d.ts +19 -0
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.d.ts.map +1 -0
- package/lib/components/dataCube/{DataCubeQueryTextEditor.js → editor/DataCubeEditorCodePanel.js} +20 -20
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js.map +1 -0
- package/lib/components/dataCube/{DataCubeGridEditor.d.ts → editor/DataCubeEditorSortPanel.d.ts} +4 -4
- package/lib/components/dataCube/editor/DataCubeEditorSortPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorSortPanel.js +61 -0
- package/lib/components/dataCube/editor/DataCubeEditorSortPanel.js.map +1 -0
- package/lib/components/dataCube/{DataCubeQueryTextEditor.d.ts → grid/DataCubeGrid.d.ts} +4 -4
- package/lib/components/dataCube/grid/DataCubeGrid.d.ts.map +1 -0
- package/lib/components/dataCube/grid/DataCubeGrid.js +59 -0
- package/lib/components/dataCube/grid/DataCubeGrid.js.map +1 -0
- package/lib/grid.css +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -8
- package/lib/index.js.map +1 -1
- package/lib/package.json +3 -3
- package/lib/repl.css +1 -1
- package/lib/server/REPLServerClient.d.ts +11 -13
- package/lib/server/REPLServerClient.d.ts.map +1 -1
- package/lib/server/REPLServerClient.js +27 -15
- package/lib/server/REPLServerClient.js.map +1 -1
- package/lib/server/models/DataCubeEngineModels.d.ts +50 -0
- package/lib/server/models/DataCubeEngineModels.d.ts.map +1 -0
- package/lib/server/models/DataCubeEngineModels.js +39 -0
- package/lib/server/models/DataCubeEngineModels.js.map +1 -0
- package/lib/server/models/DataCubeQuery.d.ts +41 -0
- package/lib/server/models/DataCubeQuery.d.ts.map +1 -0
- package/lib/server/models/DataCubeQuery.js +78 -0
- package/lib/server/models/DataCubeQuery.js.map +1 -0
- package/lib/stores/{LegendREPLGridClientApplicationPlugin.d.ts → LegendREPLApplicationPlugin.d.ts} +4 -4
- package/lib/stores/LegendREPLApplicationPlugin.d.ts.map +1 -0
- package/lib/stores/{LegendREPLGridClientApplicationPlugin.js → LegendREPLApplicationPlugin.js} +2 -2
- package/lib/stores/LegendREPLApplicationPlugin.js.map +1 -0
- package/lib/stores/LegendREPLBaseStore.d.ts +25 -0
- package/lib/stores/LegendREPLBaseStore.d.ts.map +1 -0
- package/lib/stores/{LegendREPLGridClientBaseStore.js → LegendREPLBaseStore.js} +2 -2
- package/lib/stores/LegendREPLBaseStore.js.map +1 -0
- package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts +49 -0
- package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts.map +1 -0
- package/lib/stores/dataCube/DataCubeMetaModelConst.js +57 -0
- package/lib/stores/dataCube/DataCubeMetaModelConst.js.map +1 -0
- package/lib/stores/dataCube/DataCubeState.d.ts +18 -23
- package/lib/stores/dataCube/DataCubeState.d.ts.map +1 -1
- package/lib/stores/dataCube/DataCubeState.js +31 -181
- package/lib/stores/dataCube/DataCubeState.js.map +1 -1
- package/lib/stores/{REPLGridClientStore.d.ts → dataCube/DataCubeStore.d.ts} +7 -7
- package/lib/stores/dataCube/DataCubeStore.d.ts.map +1 -0
- package/lib/stores/{REPLGridClientStore.js → dataCube/DataCubeStore.js} +5 -4
- package/lib/stores/dataCube/DataCubeStore.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeEngine.d.ts +29 -0
- package/lib/stores/dataCube/core/DataCubeEngine.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeEngine.js +47 -0
- package/lib/stores/dataCube/core/DataCubeEngine.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.d.ts +37 -0
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.js +269 -0
- package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts +19 -0
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +98 -0
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +73 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js +56 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -0
- package/lib/stores/dataCube/{DataCubePanelState.d.ts → core/DataCubeQuerySnapshotManager.d.ts} +11 -6
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.d.ts.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.js +46 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.js.map +1 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts +27 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts.map +1 -0
- package/lib/{components/grid/REPLGridServerResult.js → stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js} +18 -10
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js.map +1 -0
- package/lib/stores/dataCube/{DataCubeQueryEditorState.d.ts → editor/DataCubeEditorCodeState.d.ts} +12 -2
- package/lib/stores/dataCube/editor/DataCubeEditorCodeState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorCodeState.js +87 -0
- package/lib/stores/dataCube/editor/DataCubeEditorCodeState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.d.ts +28 -0
- package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.js +17 -0
- package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.d.ts +46 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.js +133 -0
- package/lib/stores/dataCube/editor/DataCubeEditorSortState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts +44 -0
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorState.js +77 -0
- package/lib/stores/dataCube/editor/DataCubeEditorState.js.map +1 -0
- package/lib/{components/grid/ServerSideDataSource.d.ts → stores/dataCube/grid/DataCubeGridClientEngine.d.ts} +17 -14
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +96 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts +19 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js +224 -0
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts +33 -0
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridState.js +50 -0
- package/lib/stores/dataCube/grid/DataCubeGridState.js.map +1 -0
- package/package.json +9 -9
- package/src/{Const.ts → __lib__/LegendREPLEvent.ts} +1 -16
- package/{lib/components/grid/REPLGridServerResult.d.ts → src/__lib__/LegendREPLSetting.ts} +3 -6
- package/src/application/LegendREPL.tsx +64 -0
- package/src/application/{LegendREPLGridClientApplicationConfig.ts → LegendREPLApplicationConfig.ts} +3 -3
- package/src/application/{LegendREPLGridClientPluginManager.ts → LegendREPLPluginManager.ts} +5 -5
- package/src/components/{Core_LegendREPLGridClientApplicationPlugin.tsx → Core_LegendREPLApplicationPlugin.tsx} +11 -6
- package/src/components/{LegendREPLGridClientApplication.tsx → LegendREPLApplication.tsx} +11 -28
- package/src/components/LegendREPLFrameworkProvider.tsx +57 -0
- package/src/components/{REPLGridClientStoreProvider.tsx → REPLStoreProvider.tsx} +17 -21
- package/src/components/dataCube/DataCube.tsx +63 -0
- package/src/components/dataCube/editor/DataCubeEditor.tsx +127 -0
- package/src/components/dataCube/{DataCubeQueryTextEditor.tsx → editor/DataCubeEditorCodePanel.tsx} +69 -76
- package/src/components/dataCube/editor/DataCubeEditorSortPanel.tsx +274 -0
- package/src/components/dataCube/grid/DataCubeGrid.tsx +77 -0
- package/src/index.tsx +12 -8
- package/src/server/REPLServerClient.ts +50 -78
- package/src/server/models/DataCubeEngineModels.ts +84 -0
- package/src/server/models/DataCubeQuery.ts +130 -0
- package/src/stores/{LegendREPLGridClientApplicationPlugin.ts → LegendREPLApplicationPlugin.ts} +4 -4
- package/src/stores/{LegendREPLGridClientBaseStore.ts → LegendREPLBaseStore.ts} +9 -9
- package/src/stores/dataCube/DataCubeMetaModelConst.ts +61 -0
- package/src/stores/dataCube/DataCubeState.ts +39 -303
- package/src/stores/{REPLGridClientStore.ts → dataCube/DataCubeStore.ts} +8 -6
- package/src/stores/dataCube/core/DataCubeEngine.ts +79 -0
- package/src/stores/dataCube/core/DataCubeQueryAnalyzer.ts +424 -0
- package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +151 -0
- package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +201 -0
- package/src/stores/dataCube/core/DataCubeQuerySnapshotManager.ts +67 -0
- package/src/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.ts +43 -0
- package/src/stores/dataCube/editor/DataCubeEditorCodeState.ts +166 -0
- package/src/{components/grid/REPLGridServerResult.ts → stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.ts} +14 -11
- package/src/stores/dataCube/editor/DataCubeEditorSortState.ts +198 -0
- package/src/stores/dataCube/editor/DataCubeEditorState.ts +94 -0
- package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +152 -0
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.ts +245 -0
- package/src/stores/dataCube/grid/DataCubeGridState.ts +62 -0
- package/tsconfig.json +33 -29
- package/lib/Const.d.ts +0 -32
- package/lib/Const.d.ts.map +0 -1
- package/lib/Const.js +0 -35
- package/lib/Const.js.map +0 -1
- package/lib/application/LegendREPLGridClient.d.ts.map +0 -1
- package/lib/application/LegendREPLGridClient.js.map +0 -1
- package/lib/application/LegendREPLGridClientApplicationConfig.d.ts.map +0 -1
- package/lib/application/LegendREPLGridClientApplicationConfig.js.map +0 -1
- package/lib/application/LegendREPLGridClientPluginManager.d.ts.map +0 -1
- package/lib/application/LegendREPLGridClientPluginManager.js.map +0 -1
- package/lib/components/AgGrid.d.ts.map +0 -1
- package/lib/components/AgGrid.js +0 -41
- package/lib/components/AgGrid.js.map +0 -1
- package/lib/components/Core_LegendREPLGridClientApplicationPlugin.d.ts.map +0 -1
- package/lib/components/Core_LegendREPLGridClientApplicationPlugin.js.map +0 -1
- package/lib/components/LegendREPLGridClientApplication.d.ts +0 -31
- package/lib/components/LegendREPLGridClientApplication.d.ts.map +0 -1
- package/lib/components/LegendREPLGridClientApplication.js +0 -39
- package/lib/components/LegendREPLGridClientApplication.js.map +0 -1
- package/lib/components/LegendREPLGridClientFrameworkProvider.d.ts.map +0 -1
- package/lib/components/LegendREPLGridClientFrameworkProvider.js.map +0 -1
- package/lib/components/REPLGridClient.d.ts.map +0 -1
- package/lib/components/REPLGridClient.js +0 -143
- package/lib/components/REPLGridClient.js.map +0 -1
- package/lib/components/REPLGridClientStoreProvider.d.ts.map +0 -1
- package/lib/components/REPLGridClientStoreProvider.js.map +0 -1
- package/lib/components/dataCube/DataCubeGridEditor.d.ts.map +0 -1
- package/lib/components/dataCube/DataCubeGridEditor.js +0 -37
- package/lib/components/dataCube/DataCubeGridEditor.js.map +0 -1
- package/lib/components/dataCube/DataCubeQueryTextEditor.d.ts.map +0 -1
- package/lib/components/dataCube/DataCubeQueryTextEditor.js.map +0 -1
- package/lib/components/grid/GridUtils.d.ts +0 -31
- package/lib/components/grid/GridUtils.d.ts.map +0 -1
- package/lib/components/grid/GridUtils.js +0 -174
- package/lib/components/grid/GridUtils.js.map +0 -1
- package/lib/components/grid/REPLGridServerResult.d.ts.map +0 -1
- package/lib/components/grid/REPLGridServerResult.js.map +0 -1
- package/lib/components/grid/ServerSideDataSource.d.ts.map +0 -1
- package/lib/components/grid/ServerSideDataSource.js +0 -109
- package/lib/components/grid/ServerSideDataSource.js.map +0 -1
- package/lib/components/grid/TDSLambdaBuilder.d.ts.map +0 -1
- package/lib/components/grid/TDSLambdaBuilder.js +0 -314
- package/lib/components/grid/TDSLambdaBuilder.js.map +0 -1
- package/lib/components/grid/TDSQuery.d.ts +0 -25
- package/lib/components/grid/TDSQuery.d.ts.map +0 -1
- package/lib/components/grid/TDSQuery.js +0 -32
- package/lib/components/grid/TDSQuery.js.map +0 -1
- package/lib/components/grid/TDSRequest.d.ts +0 -103
- package/lib/components/grid/TDSRequest.d.ts.map +0 -1
- package/lib/components/grid/TDSRequest.js +0 -172
- package/lib/components/grid/TDSRequest.js.map +0 -1
- package/lib/stores/CompletionResult.d.ts.map +0 -1
- package/lib/stores/CompletionResult.js +0 -26
- package/lib/stores/CompletionResult.js.map +0 -1
- package/lib/stores/LegendREPLGridClientApplicationPlugin.d.ts.map +0 -1
- package/lib/stores/LegendREPLGridClientApplicationPlugin.js.map +0 -1
- package/lib/stores/LegendREPLGridClientBaseStore.d.ts +0 -25
- package/lib/stores/LegendREPLGridClientBaseStore.d.ts.map +0 -1
- package/lib/stores/LegendREPLGridClientBaseStore.js.map +0 -1
- package/lib/stores/REPLGridClientStore.d.ts.map +0 -1
- package/lib/stores/REPLGridClientStore.js.map +0 -1
- package/lib/stores/dataCube/DataCubeConfigState.d.ts +0 -32
- package/lib/stores/dataCube/DataCubeConfigState.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubeConfigState.js +0 -62
- package/lib/stores/dataCube/DataCubeConfigState.js.map +0 -1
- package/lib/stores/dataCube/DataCubeGridState.d.ts +0 -39
- package/lib/stores/dataCube/DataCubeGridState.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubeGridState.js +0 -108
- package/lib/stores/dataCube/DataCubeGridState.js.map +0 -1
- package/lib/stores/dataCube/DataCubePanelState.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubePanelState.js.map +0 -1
- package/lib/stores/dataCube/DataCubePropertiesPanelState.d.ts +0 -34
- package/lib/stores/dataCube/DataCubePropertiesPanelState.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubePropertiesPanelState.js +0 -57
- package/lib/stores/dataCube/DataCubePropertiesPanelState.js.map +0 -1
- package/lib/stores/dataCube/DataCubeQueryEditorState.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubeQueryEditorState.js +0 -49
- package/lib/stores/dataCube/DataCubeQueryEditorState.js.map +0 -1
- package/lib/stores/dataCube/DataCubeQueryTextEditorState.d.ts +0 -25
- package/lib/stores/dataCube/DataCubeQueryTextEditorState.d.ts.map +0 -1
- package/lib/stores/dataCube/DataCubeQueryTextEditorState.js +0 -35
- package/lib/stores/dataCube/DataCubeQueryTextEditorState.js.map +0 -1
- package/lib/stores/dataCube/HPivotAndSortPanelState.d.ts +0 -40
- package/lib/stores/dataCube/HPivotAndSortPanelState.d.ts.map +0 -1
- package/lib/stores/dataCube/HPivotAndSortPanelState.js +0 -130
- package/lib/stores/dataCube/HPivotAndSortPanelState.js.map +0 -1
- package/src/application/LegendREPLGridClient.tsx +0 -72
- package/src/components/AgGrid.tsx +0 -59
- package/src/components/LegendREPLGridClientFrameworkProvider.tsx +0 -63
- package/src/components/REPLGridClient.tsx +0 -560
- package/src/components/dataCube/DataCubeGridEditor.tsx +0 -69
- package/src/components/grid/GridUtils.ts +0 -220
- package/src/components/grid/ServerSideDataSource.ts +0 -197
- package/src/components/grid/TDSLambdaBuilder.ts +0 -456
- package/src/components/grid/TDSQuery.ts +0 -37
- package/src/components/grid/TDSRequest.ts +0 -231
- package/src/stores/CompletionResult.ts +0 -30
- package/src/stores/dataCube/DataCubeConfigState.ts +0 -79
- package/src/stores/dataCube/DataCubeGridState.ts +0 -143
- package/src/stores/dataCube/DataCubePanelState.ts +0 -28
- package/src/stores/dataCube/DataCubePropertiesPanelState.ts +0 -65
- package/src/stores/dataCube/DataCubeQueryEditorState.ts +0 -66
- package/src/stores/dataCube/DataCubeQueryTextEditorState.ts +0 -41
- package/src/stores/dataCube/HPivotAndSortPanelState.ts +0 -170
|
@@ -0,0 +1,79 @@
|
|
|
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 {
|
|
18
|
+
type V1_Lambda,
|
|
19
|
+
V1_deserializeValueSpecification,
|
|
20
|
+
V1_serializeValueSpecification,
|
|
21
|
+
type V1_ValueSpecification,
|
|
22
|
+
TDSExecutionResult,
|
|
23
|
+
V1_serializeExecutionResult,
|
|
24
|
+
V1_buildExecutionResult,
|
|
25
|
+
} from '@finos/legend-graph';
|
|
26
|
+
import type { REPLServerClient } from '../../../server/REPLServerClient.js';
|
|
27
|
+
import { type CompletionItem } from '../../../server/models/DataCubeEngineModels.js';
|
|
28
|
+
import { DataCubeQuery } from '../../../server/models/DataCubeQuery.js';
|
|
29
|
+
import { guaranteeType } from '@finos/legend-shared';
|
|
30
|
+
|
|
31
|
+
export class DataCubeEngine {
|
|
32
|
+
private readonly client: REPLServerClient;
|
|
33
|
+
|
|
34
|
+
constructor(client: REPLServerClient) {
|
|
35
|
+
this.client = client;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async getGridClientLicenseKey(): Promise<string> {
|
|
39
|
+
return this.client.getGridClientLicenseKey();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async getQueryTypeahead(
|
|
43
|
+
code: string,
|
|
44
|
+
isPartial?: boolean,
|
|
45
|
+
): Promise<CompletionItem[]> {
|
|
46
|
+
return (await this.client.getQueryTypeahead({
|
|
47
|
+
code,
|
|
48
|
+
isPartial,
|
|
49
|
+
})) as CompletionItem[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async parseQuery(
|
|
53
|
+
code: string,
|
|
54
|
+
returnSourceInformation?: boolean,
|
|
55
|
+
): Promise<V1_ValueSpecification> {
|
|
56
|
+
return V1_deserializeValueSpecification(
|
|
57
|
+
await this.client.parseQuery({ code, returnSourceInformation }),
|
|
58
|
+
[],
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async getBaseQuery(): Promise<DataCubeQuery> {
|
|
63
|
+
return DataCubeQuery.serialization.fromJson(
|
|
64
|
+
await this.client.getBaseQuery(),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async executeQuery(query: V1_Lambda): Promise<TDSExecutionResult> {
|
|
69
|
+
const result = await this.client.executeQuery({
|
|
70
|
+
query: V1_serializeValueSpecification(query, []),
|
|
71
|
+
});
|
|
72
|
+
return guaranteeType(
|
|
73
|
+
V1_buildExecutionResult(
|
|
74
|
+
V1_serializeExecutionResult(JSON.parse(result.result)),
|
|
75
|
+
),
|
|
76
|
+
TDSExecutionResult,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,424 @@
|
|
|
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 {
|
|
18
|
+
V1_AppliedFunction,
|
|
19
|
+
V1_ClassInstance,
|
|
20
|
+
V1_ColSpec,
|
|
21
|
+
V1_Collection,
|
|
22
|
+
V1_serializeValueSpecification,
|
|
23
|
+
extractElementNameFromPath,
|
|
24
|
+
matchFunctionName,
|
|
25
|
+
type V1_ValueSpecification,
|
|
26
|
+
} from '@finos/legend-graph';
|
|
27
|
+
import {
|
|
28
|
+
DATA_CUBE_FUNCTIONS,
|
|
29
|
+
DATA_CUBE_COLUMN_SORT_DIRECTION,
|
|
30
|
+
} from '../DataCubeMetaModelConst.js';
|
|
31
|
+
import type { DataCubeQuery } from '../../../server/models/DataCubeQuery.js';
|
|
32
|
+
import {
|
|
33
|
+
DataCubeQuerySnapshotColumnOrigin,
|
|
34
|
+
createSnapshot,
|
|
35
|
+
type DataCubeQuerySnapshotColumnWithOrigin,
|
|
36
|
+
} from './DataCubeQuerySnapshot.js';
|
|
37
|
+
import {
|
|
38
|
+
assertErrorThrown,
|
|
39
|
+
assertTrue,
|
|
40
|
+
assertType,
|
|
41
|
+
guaranteeNonNullable,
|
|
42
|
+
} from '@finos/legend-shared';
|
|
43
|
+
import type { DataCubeEngine } from './DataCubeEngine.js';
|
|
44
|
+
|
|
45
|
+
const _SUPPORTED_TOP_LEVEL_FUNCTIONS: {
|
|
46
|
+
func: string;
|
|
47
|
+
parameters: number;
|
|
48
|
+
}[] = [
|
|
49
|
+
{ func: DATA_CUBE_FUNCTIONS.EXTEND, parameters: 1 },
|
|
50
|
+
{ func: DATA_CUBE_FUNCTIONS.FILTER, parameters: 1 },
|
|
51
|
+
{ func: DATA_CUBE_FUNCTIONS.GROUP_BY, parameters: 3 },
|
|
52
|
+
{ func: DATA_CUBE_FUNCTIONS.LIMIT, parameters: 1 },
|
|
53
|
+
{ func: DATA_CUBE_FUNCTIONS.PIVOT, parameters: 3 },
|
|
54
|
+
{ func: DATA_CUBE_FUNCTIONS.RENAME, parameters: 2 },
|
|
55
|
+
{ func: DATA_CUBE_FUNCTIONS.SELECT, parameters: 1 },
|
|
56
|
+
{ func: DATA_CUBE_FUNCTIONS.SORT, parameters: 1 },
|
|
57
|
+
|
|
58
|
+
{ func: DATA_CUBE_FUNCTIONS.CAST, parameters: 1 },
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
// NOTE: this corresponds to the sequence:
|
|
62
|
+
// extend()->rename()->filter()->groupBy()->select()->pivot()->cast()->extend()->sort()->limit()
|
|
63
|
+
// which represents the ONLY query shape that we currently support
|
|
64
|
+
const _FUNCTION_SEQUENCE_COMPOSITION_PATTERN: {
|
|
65
|
+
func: string;
|
|
66
|
+
repeat?: boolean | undefined;
|
|
67
|
+
required?: boolean | undefined;
|
|
68
|
+
}[] = [
|
|
69
|
+
{ func: DATA_CUBE_FUNCTIONS.EXTEND },
|
|
70
|
+
{ func: DATA_CUBE_FUNCTIONS.RENAME, repeat: true }, // rename() can be repeated since each call only allow renaming one column
|
|
71
|
+
{ func: DATA_CUBE_FUNCTIONS.FILTER },
|
|
72
|
+
{ func: DATA_CUBE_FUNCTIONS.GROUP_BY },
|
|
73
|
+
{ func: DATA_CUBE_FUNCTIONS.SELECT },
|
|
74
|
+
{ func: DATA_CUBE_FUNCTIONS.PIVOT },
|
|
75
|
+
{ func: DATA_CUBE_FUNCTIONS.CAST },
|
|
76
|
+
{ func: DATA_CUBE_FUNCTIONS.EXTEND },
|
|
77
|
+
{ func: DATA_CUBE_FUNCTIONS.SORT },
|
|
78
|
+
{ func: DATA_CUBE_FUNCTIONS.LIMIT },
|
|
79
|
+
];
|
|
80
|
+
const _FUNCTION_SEQUENCE_COMPOSITION_PATTERN_REGEXP = new RegExp(
|
|
81
|
+
`^${_FUNCTION_SEQUENCE_COMPOSITION_PATTERN
|
|
82
|
+
.map(
|
|
83
|
+
(entry) =>
|
|
84
|
+
`(?:<${extractElementNameFromPath(entry.func)}>)${entry.repeat ? '*' : !entry.required ? '?' : ''}`,
|
|
85
|
+
)
|
|
86
|
+
.join('')}$`,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Since the query created by DataCube will be a chain call of various functions,
|
|
91
|
+
* this utility function will extract that sequence of function calls as well as
|
|
92
|
+
* do various basic checks for the validity, composition, and order of those functions.
|
|
93
|
+
*/
|
|
94
|
+
function extractQueryFunctionSequence(query: V1_ValueSpecification) {
|
|
95
|
+
// Make sure this is a sequence of function calls
|
|
96
|
+
if (!(query instanceof V1_AppliedFunction)) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`Query sequence must be a sequence of function calls (e.g. x()->y()->z())`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const sequence: V1_AppliedFunction[] = [];
|
|
102
|
+
let currentQuery = query;
|
|
103
|
+
while (currentQuery instanceof V1_AppliedFunction) {
|
|
104
|
+
const supportedFunc = _SUPPORTED_TOP_LEVEL_FUNCTIONS.find((spec) =>
|
|
105
|
+
matchFunctionName(currentQuery.function, spec.func),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Check that all functions in sequence are supported
|
|
109
|
+
if (!supportedFunc) {
|
|
110
|
+
throw new Error(`Found unsupported function ${currentQuery.function}()`);
|
|
111
|
+
}
|
|
112
|
+
if (currentQuery.parameters.length > supportedFunc.parameters) {
|
|
113
|
+
const vs = currentQuery.parameters[0];
|
|
114
|
+
if (!(vs instanceof V1_AppliedFunction)) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Query sequence must be a sequence of function calls (e.g. x()->y()->z())`,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
currentQuery.parameters = currentQuery.parameters.slice(1);
|
|
120
|
+
sequence.unshift(currentQuery);
|
|
121
|
+
currentQuery = vs;
|
|
122
|
+
} else {
|
|
123
|
+
sequence.unshift(currentQuery);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Check that sequence follows the supported pattern
|
|
129
|
+
const sequenceFormText = sequence
|
|
130
|
+
.map((func) => `<${extractElementNameFromPath(func.function)}>`)
|
|
131
|
+
.join('');
|
|
132
|
+
if (!sequenceFormText.match(_FUNCTION_SEQUENCE_COMPOSITION_PATTERN_REGEXP)) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Unsupported function composition ${sequence.map((fn) => `${extractElementNameFromPath(fn.function)}()`).join('->')} (supported composition: ${_FUNCTION_SEQUENCE_COMPOSITION_PATTERN.map((entry) => `${extractElementNameFromPath(entry.func)}()`).join('->')})`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Special checks
|
|
139
|
+
// Check that the first and second extend() must be separated by either groupBy() or pivot() (i.e. aggregation)
|
|
140
|
+
const firstExtendIndex = sequence.findIndex((func) =>
|
|
141
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.EXTEND),
|
|
142
|
+
);
|
|
143
|
+
const secondExtendIndex = sequence.findLastIndex((func) =>
|
|
144
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.EXTEND),
|
|
145
|
+
);
|
|
146
|
+
if (firstExtendIndex !== -1 && firstExtendIndex !== secondExtendIndex) {
|
|
147
|
+
const seq = sequence.slice(firstExtendIndex + 1, secondExtendIndex);
|
|
148
|
+
if (
|
|
149
|
+
!seq.some(
|
|
150
|
+
(func) =>
|
|
151
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.GROUP_BY) ||
|
|
152
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.PIVOT),
|
|
153
|
+
)
|
|
154
|
+
) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`Found invalid usage of group-level extend() for query without aggregation such as pivot() and groupBy()`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Check that pivot() and cast() must co-present and stand consecutively in the sequence
|
|
162
|
+
const pivotFunc = sequence.find((func) =>
|
|
163
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.PIVOT),
|
|
164
|
+
);
|
|
165
|
+
const castFunc = sequence.find((func) =>
|
|
166
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.CAST),
|
|
167
|
+
);
|
|
168
|
+
if (Boolean(pivotFunc) !== Boolean(castFunc)) {
|
|
169
|
+
throw new Error(`Found usage of dynamic function pivot() without casting`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return sequence;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
type FunctionMap = {
|
|
176
|
+
leafExtend: V1_AppliedFunction | undefined;
|
|
177
|
+
rename: V1_AppliedFunction[] | undefined;
|
|
178
|
+
filter: V1_AppliedFunction | undefined;
|
|
179
|
+
groupBy: V1_AppliedFunction | undefined;
|
|
180
|
+
select: V1_AppliedFunction | undefined;
|
|
181
|
+
pivot: V1_AppliedFunction | undefined;
|
|
182
|
+
cast: V1_AppliedFunction | undefined;
|
|
183
|
+
groupExtend: V1_AppliedFunction | undefined;
|
|
184
|
+
sort: V1_AppliedFunction | undefined;
|
|
185
|
+
limit: V1_AppliedFunction | undefined;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Turn the function sequence into a map of available functions
|
|
190
|
+
* for easier construction of the snapshot
|
|
191
|
+
*/
|
|
192
|
+
function extractFunctionMap(sequence: V1_AppliedFunction[]): FunctionMap {
|
|
193
|
+
let leafExtend: V1_AppliedFunction | undefined = undefined;
|
|
194
|
+
let groupExtend: V1_AppliedFunction | undefined = undefined;
|
|
195
|
+
const aggregationFuncIndex = sequence.findLastIndex((func) =>
|
|
196
|
+
matchFunctionName(func.function, [
|
|
197
|
+
DATA_CUBE_FUNCTIONS.PIVOT,
|
|
198
|
+
DATA_CUBE_FUNCTIONS.GROUP_BY,
|
|
199
|
+
]),
|
|
200
|
+
);
|
|
201
|
+
const firstExtendIndex = sequence.findIndex((func) =>
|
|
202
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.EXTEND),
|
|
203
|
+
);
|
|
204
|
+
const secondExtendIndex = sequence.findLastIndex((func) =>
|
|
205
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.EXTEND),
|
|
206
|
+
);
|
|
207
|
+
if (aggregationFuncIndex !== -1) {
|
|
208
|
+
if (firstExtendIndex !== secondExtendIndex) {
|
|
209
|
+
leafExtend = sequence[firstExtendIndex];
|
|
210
|
+
groupExtend = sequence[secondExtendIndex];
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
if (firstExtendIndex !== -1) {
|
|
214
|
+
leafExtend = sequence[firstExtendIndex];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const rename = sequence.filter((func) =>
|
|
219
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.RENAME),
|
|
220
|
+
);
|
|
221
|
+
const filter = sequence.find((func) =>
|
|
222
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.FILTER),
|
|
223
|
+
);
|
|
224
|
+
const groupBy = sequence.find((func) =>
|
|
225
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.GROUP_BY),
|
|
226
|
+
);
|
|
227
|
+
const select = sequence.find((func) =>
|
|
228
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.SELECT),
|
|
229
|
+
);
|
|
230
|
+
const pivot = sequence.find((func) =>
|
|
231
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.PIVOT),
|
|
232
|
+
);
|
|
233
|
+
const cast = sequence.find((func) =>
|
|
234
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.CAST),
|
|
235
|
+
);
|
|
236
|
+
const sort = sequence.find((func) =>
|
|
237
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.SORT),
|
|
238
|
+
);
|
|
239
|
+
const limit = sequence.find((func) =>
|
|
240
|
+
matchFunctionName(func.function, DATA_CUBE_FUNCTIONS.LIMIT),
|
|
241
|
+
);
|
|
242
|
+
return {
|
|
243
|
+
leafExtend,
|
|
244
|
+
rename,
|
|
245
|
+
filter,
|
|
246
|
+
groupBy,
|
|
247
|
+
select,
|
|
248
|
+
pivot,
|
|
249
|
+
cast,
|
|
250
|
+
groupExtend,
|
|
251
|
+
sort,
|
|
252
|
+
limit,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Analyze the partial query to build the base snapshot.
|
|
258
|
+
*
|
|
259
|
+
* NOTE: the base snapshot is almost, but not a complete snapshot.
|
|
260
|
+
* It has key information about the partial query filled in, these are the bits
|
|
261
|
+
* required to reconstruct the query just from the snapshot.
|
|
262
|
+
* However, it lacks analytics information, such as extended columns' lambda code,
|
|
263
|
+
* which might be useful for initializing the editors. These should get filled in
|
|
264
|
+
* at a later stage in the analysis/initialization flow.
|
|
265
|
+
*
|
|
266
|
+
* Implementation-wise, this extracts the function call sequence, then walk the
|
|
267
|
+
* sequence in order to fill in the information for the snapshot.
|
|
268
|
+
*/
|
|
269
|
+
export function validateAndBuildBaseSnapshot(
|
|
270
|
+
baseQuery: DataCubeQuery,
|
|
271
|
+
analytics: {
|
|
272
|
+
sourceQuery: V1_ValueSpecification;
|
|
273
|
+
partialQuery: V1_ValueSpecification | undefined;
|
|
274
|
+
},
|
|
275
|
+
) {
|
|
276
|
+
// --------------------------------- BASE ---------------------------------
|
|
277
|
+
// Build the function call sequence and the function map to make the
|
|
278
|
+
// analysis more ergonomic
|
|
279
|
+
|
|
280
|
+
const { partialQuery, sourceQuery } = analytics;
|
|
281
|
+
const sequence = partialQuery
|
|
282
|
+
? extractQueryFunctionSequence(partialQuery)
|
|
283
|
+
: [];
|
|
284
|
+
const funcMap = extractFunctionMap(sequence);
|
|
285
|
+
const snapshot = createSnapshot(
|
|
286
|
+
baseQuery.name,
|
|
287
|
+
baseQuery.source.runtime,
|
|
288
|
+
V1_serializeValueSpecification(sourceQuery, []),
|
|
289
|
+
baseQuery.configuration,
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
// --------------------------------- SOURCE ---------------------------------
|
|
293
|
+
|
|
294
|
+
snapshot.originalColumns = baseQuery.source.columns;
|
|
295
|
+
const columns: DataCubeQuerySnapshotColumnWithOrigin[] =
|
|
296
|
+
snapshot.originalColumns.map((col) => ({
|
|
297
|
+
...col,
|
|
298
|
+
origin: DataCubeQuerySnapshotColumnOrigin.SOURCE,
|
|
299
|
+
}));
|
|
300
|
+
|
|
301
|
+
// leafExtendedColumns: DataCubeQueryExtendedColumnSnapshot[] = [];
|
|
302
|
+
// filter: ValueSpecification[0..1]; // TODO
|
|
303
|
+
// renamedColumns: DataCubeQuerySnapshotRenamedColumn[] = [];
|
|
304
|
+
// groupByColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
305
|
+
// groupByAggColumns: DataCubeQuerySnapshotAggregateColumn[] = [];
|
|
306
|
+
// selectedColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
307
|
+
// pivotColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
308
|
+
// pivotAggColumns: DataCubeQuerySnapshotAggregateColumn[] = [];
|
|
309
|
+
// castColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
310
|
+
// groupExtendedColumns: DataCubeQueryExtendedColumnSnapshot[] = [];
|
|
311
|
+
// limit: number | undefined = undefined;
|
|
312
|
+
// configuration: DataCubeConfiguration;
|
|
313
|
+
|
|
314
|
+
// --------------------------------- LEAF EXTEND ---------------------------------
|
|
315
|
+
// TODO: @akphi - implement this
|
|
316
|
+
|
|
317
|
+
// --------------------------------- FILTER ---------------------------------
|
|
318
|
+
// TODO: @akphi - implement this
|
|
319
|
+
|
|
320
|
+
// --------------------------------- RENAME ---------------------------------
|
|
321
|
+
// TODO: @akphi - implement this
|
|
322
|
+
|
|
323
|
+
// --------------------------------- GROUP BY ---------------------------------
|
|
324
|
+
// TODO: @akphi - implement this
|
|
325
|
+
|
|
326
|
+
// --------------------------------- SELECT ---------------------------------
|
|
327
|
+
// TODO: @akphi - implement this
|
|
328
|
+
|
|
329
|
+
// --------------------------------- PIVOT ---------------------------------
|
|
330
|
+
// TODO: @akphi - implement this
|
|
331
|
+
|
|
332
|
+
// --------------------------------- CAST ---------------------------------
|
|
333
|
+
// TODO: @akphi - implement this
|
|
334
|
+
|
|
335
|
+
// --------------------------------- GROUP EXTEND ---------------------------------
|
|
336
|
+
// TODO: @akphi - implement this
|
|
337
|
+
|
|
338
|
+
// --------------------------------- SORT ---------------------------------
|
|
339
|
+
|
|
340
|
+
if (funcMap.sort) {
|
|
341
|
+
const sortColumns = funcMap.sort.parameters[0];
|
|
342
|
+
assertType(
|
|
343
|
+
sortColumns,
|
|
344
|
+
V1_Collection,
|
|
345
|
+
`Can't process ${extractElementNameFromPath(
|
|
346
|
+
DATA_CUBE_FUNCTIONS.SORT,
|
|
347
|
+
)}(): columns cannot be extracted`,
|
|
348
|
+
);
|
|
349
|
+
snapshot.sortColumns = sortColumns.values.map((col) => {
|
|
350
|
+
try {
|
|
351
|
+
assertType(col, V1_AppliedFunction);
|
|
352
|
+
assertTrue(
|
|
353
|
+
matchFunctionName(col.function, [
|
|
354
|
+
DATA_CUBE_FUNCTIONS.ASC,
|
|
355
|
+
DATA_CUBE_FUNCTIONS.DESC,
|
|
356
|
+
]),
|
|
357
|
+
);
|
|
358
|
+
const direction =
|
|
359
|
+
extractElementNameFromPath(col.function) === DATA_CUBE_FUNCTIONS.ASC
|
|
360
|
+
? DATA_CUBE_COLUMN_SORT_DIRECTION.ASCENDING
|
|
361
|
+
: DATA_CUBE_COLUMN_SORT_DIRECTION.DESCENDING;
|
|
362
|
+
assertTrue(col.parameters.length === 1);
|
|
363
|
+
assertType(col.parameters[0], V1_ClassInstance);
|
|
364
|
+
assertType(col.parameters[0].value, V1_ColSpec);
|
|
365
|
+
const name = col.parameters[0].value.name;
|
|
366
|
+
const type = guaranteeNonNullable(
|
|
367
|
+
columns.find((c) => c.name === name),
|
|
368
|
+
).type;
|
|
369
|
+
return { name, type, direction };
|
|
370
|
+
} catch {
|
|
371
|
+
throw new Error(
|
|
372
|
+
`Can't process ${extractElementNameFromPath(
|
|
373
|
+
DATA_CUBE_FUNCTIONS.SORT,
|
|
374
|
+
)}(): column sort information cannot be extracted`,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// --------------------------------- LIMIT ---------------------------------
|
|
381
|
+
// TODO: @akphi - implement this
|
|
382
|
+
|
|
383
|
+
// --------------------------------- FINALIZE ---------------------------------
|
|
384
|
+
|
|
385
|
+
snapshot.columns = columns;
|
|
386
|
+
|
|
387
|
+
return snapshot;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export async function buildSnapshotFromQuery(
|
|
391
|
+
baseQuery: DataCubeQuery,
|
|
392
|
+
engine: DataCubeEngine,
|
|
393
|
+
) {
|
|
394
|
+
let partialQuery: V1_ValueSpecification | undefined;
|
|
395
|
+
if (baseQuery.partialQuery) {
|
|
396
|
+
try {
|
|
397
|
+
partialQuery = await engine.parseQuery(baseQuery.partialQuery);
|
|
398
|
+
} catch (error) {
|
|
399
|
+
assertErrorThrown(error);
|
|
400
|
+
throw new Error(
|
|
401
|
+
`Can't parse partial query [${baseQuery.partialQuery}]: ${error.message}`,
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
partialQuery = undefined;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
let sourceQuery: V1_ValueSpecification;
|
|
409
|
+
try {
|
|
410
|
+
sourceQuery = await engine.parseQuery(baseQuery.source.query);
|
|
411
|
+
} catch (error) {
|
|
412
|
+
assertErrorThrown(error);
|
|
413
|
+
throw new Error(
|
|
414
|
+
`Can't parse source query [${baseQuery.source.query}]: ${error.message}`,
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const snapshot = validateAndBuildBaseSnapshot(baseQuery, {
|
|
419
|
+
partialQuery,
|
|
420
|
+
sourceQuery,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
return snapshot;
|
|
424
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
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 {
|
|
18
|
+
V1_AppliedFunction,
|
|
19
|
+
V1_ClassInstance,
|
|
20
|
+
V1_ClassInstanceType,
|
|
21
|
+
V1_ColSpec,
|
|
22
|
+
V1_Collection,
|
|
23
|
+
V1_Multiplicity,
|
|
24
|
+
V1_PackageableElementPtr,
|
|
25
|
+
V1_deserializeValueSpecification,
|
|
26
|
+
extractElementNameFromPath,
|
|
27
|
+
type V1_Lambda,
|
|
28
|
+
type V1_ValueSpecification,
|
|
29
|
+
} from '@finos/legend-graph';
|
|
30
|
+
import type { DataCubeQuerySnapshot } from './DataCubeQuerySnapshot.js';
|
|
31
|
+
import { guaranteeNonNullable } from '@finos/legend-shared';
|
|
32
|
+
import {
|
|
33
|
+
DATA_CUBE_COLUMN_SORT_DIRECTION,
|
|
34
|
+
DATA_CUBE_FUNCTIONS,
|
|
35
|
+
} from '../DataCubeMetaModelConst.js';
|
|
36
|
+
|
|
37
|
+
function createColSpec(
|
|
38
|
+
name: string,
|
|
39
|
+
type?: string | undefined,
|
|
40
|
+
function1?: V1_Lambda | undefined,
|
|
41
|
+
function2?: V1_Lambda | undefined,
|
|
42
|
+
): V1_ClassInstance {
|
|
43
|
+
const instance = new V1_ClassInstance();
|
|
44
|
+
instance.type = V1_ClassInstanceType.COL_SPEC;
|
|
45
|
+
const colSpec = new V1_ColSpec();
|
|
46
|
+
colSpec.name = name;
|
|
47
|
+
colSpec.type = type;
|
|
48
|
+
colSpec.function1 = function1;
|
|
49
|
+
colSpec.function2 = function2;
|
|
50
|
+
instance.value = colSpec;
|
|
51
|
+
return instance;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function buildExecutableQueryFromSnapshot(
|
|
55
|
+
snapshot: DataCubeQuerySnapshot,
|
|
56
|
+
): V1_ValueSpecification {
|
|
57
|
+
const sourceQuery = V1_deserializeValueSpecification(
|
|
58
|
+
snapshot.sourceQuery,
|
|
59
|
+
[],
|
|
60
|
+
);
|
|
61
|
+
const sequence: V1_AppliedFunction[] = [];
|
|
62
|
+
|
|
63
|
+
// --------------------------------- LEAF EXTEND ---------------------------------
|
|
64
|
+
// TODO: @akphi - implement this
|
|
65
|
+
|
|
66
|
+
// --------------------------------- FILTER ---------------------------------
|
|
67
|
+
// TODO: @akphi - implement this
|
|
68
|
+
|
|
69
|
+
// --------------------------------- RENAME ---------------------------------
|
|
70
|
+
// TODO: @akphi - implement this
|
|
71
|
+
|
|
72
|
+
// --------------------------------- GROUP BY ---------------------------------
|
|
73
|
+
// TODO: @akphi - implement this
|
|
74
|
+
|
|
75
|
+
// --------------------------------- SELECT ---------------------------------
|
|
76
|
+
// TODO: @akphi - implement this
|
|
77
|
+
|
|
78
|
+
// --------------------------------- PIVOT ---------------------------------
|
|
79
|
+
// TODO: @akphi - implement this
|
|
80
|
+
|
|
81
|
+
// --------------------------------- CAST ---------------------------------
|
|
82
|
+
// TODO: @akphi - implement this
|
|
83
|
+
|
|
84
|
+
// --------------------------------- GROUP EXTEND ---------------------------------
|
|
85
|
+
// TODO: @akphi - implement this
|
|
86
|
+
|
|
87
|
+
// --------------------------------- SORT ---------------------------------
|
|
88
|
+
|
|
89
|
+
if (snapshot.sortColumns.length) {
|
|
90
|
+
const sort = new V1_AppliedFunction();
|
|
91
|
+
sort.function = extractElementNameFromPath(DATA_CUBE_FUNCTIONS.SORT);
|
|
92
|
+
const sortInfos = new V1_Collection();
|
|
93
|
+
sortInfos.multiplicity = new V1_Multiplicity(
|
|
94
|
+
snapshot.sortColumns.length,
|
|
95
|
+
snapshot.sortColumns.length,
|
|
96
|
+
);
|
|
97
|
+
snapshot.sortColumns.forEach((sortCol) => {
|
|
98
|
+
const sortInfo = new V1_AppliedFunction();
|
|
99
|
+
sortInfo.function = extractElementNameFromPath(
|
|
100
|
+
sortCol.direction === DATA_CUBE_COLUMN_SORT_DIRECTION.ASCENDING
|
|
101
|
+
? DATA_CUBE_FUNCTIONS.ASC
|
|
102
|
+
: DATA_CUBE_FUNCTIONS.DESC,
|
|
103
|
+
);
|
|
104
|
+
sortInfo.parameters.push(createColSpec(sortCol.name));
|
|
105
|
+
sortInfos.values.push(sortInfo);
|
|
106
|
+
});
|
|
107
|
+
sort.parameters.push(sortInfos);
|
|
108
|
+
sequence.push(sort);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// --------------------------------- LIMIT ---------------------------------
|
|
112
|
+
// TODO: @akphi - implement this
|
|
113
|
+
|
|
114
|
+
// --------------------------------- FROM ---------------------------------
|
|
115
|
+
|
|
116
|
+
const fromFunc = new V1_AppliedFunction();
|
|
117
|
+
fromFunc.function = extractElementNameFromPath(DATA_CUBE_FUNCTIONS.FROM);
|
|
118
|
+
const runtimePtr = new V1_PackageableElementPtr();
|
|
119
|
+
runtimePtr.fullPath = snapshot.runtime;
|
|
120
|
+
fromFunc.parameters.push(runtimePtr);
|
|
121
|
+
sequence.push(fromFunc);
|
|
122
|
+
|
|
123
|
+
// --------------------------------- FINALIZE ---------------------------------
|
|
124
|
+
|
|
125
|
+
if (!sequence.length) {
|
|
126
|
+
return sourceQuery;
|
|
127
|
+
}
|
|
128
|
+
for (let i = 0; i < sequence.length; i++) {
|
|
129
|
+
guaranteeNonNullable(sequence[i]).parameters.unshift(
|
|
130
|
+
i === 0 ? sourceQuery : guaranteeNonNullable(sequence[i - 1]),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return guaranteeNonNullable(sequence[sequence.length - 1]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// export async function buildPersistentQueryFromSnapshot(
|
|
138
|
+
// snapshot: DataCubeQuerySnapshot,
|
|
139
|
+
// ) {
|
|
140
|
+
// return new DataCubeQuery(
|
|
141
|
+
// snapshot.name,
|
|
142
|
+
// snapshot.sourceQuery,
|
|
143
|
+
// snapshot.configuration,
|
|
144
|
+
// );
|
|
145
|
+
// }
|
|
146
|
+
|
|
147
|
+
// name!: string;
|
|
148
|
+
// query!: string;
|
|
149
|
+
// partialQuery!: string;
|
|
150
|
+
// source!: DataCubeQuerySource;
|
|
151
|
+
// configuration!: DataCubeConfiguration;
|