@finos/legend-query-builder 4.15.34 → 4.15.36
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilder.js +1 -1
- package/lib/components/QueryBuilder.js.map +1 -1
- package/lib/components/QueryLoader.d.ts.map +1 -1
- package/lib/components/QueryLoader.js +34 -30
- package/lib/components/QueryLoader.js.map +1 -1
- package/lib/components/data-cube/QueryBuilderDataCube.d.ts +2 -2
- package/lib/components/data-cube/QueryBuilderDataCube.d.ts.map +1 -1
- package/lib/components/data-cube/QueryBuilderDataCube.js +2 -2
- package/lib/components/data-cube/QueryBuilderDataCube.js.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.js +5 -4
- package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +4 -4
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderState.d.ts +4 -4
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +8 -8
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryLoaderState.d.ts +4 -4
- package/lib/stores/QueryLoaderState.d.ts.map +1 -1
- package/lib/stores/QueryLoaderState.js +12 -12
- package/lib/stores/QueryLoaderState.js.map +1 -1
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts +6 -7
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts.map +1 -1
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js +13 -14
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js.map +1 -1
- package/lib/stores/data-cube/{QueryBuilderDataCubeEngineHelper.d.ts → QueryBuilderDataCubeHelper.d.ts} +3 -3
- package/lib/stores/data-cube/QueryBuilderDataCubeHelper.d.ts.map +1 -0
- package/lib/stores/data-cube/{QueryBuilderDataCubeEngineHelper.js → QueryBuilderDataCubeHelper.js} +10 -6
- package/lib/stores/data-cube/QueryBuilderDataCubeHelper.js.map +1 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeViewerState.d.ts +23 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeViewerState.d.ts.map +1 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeViewerState.js +24 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeViewerState.js.map +1 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.js +4 -4
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.js.map +1 -1
- package/package.json +10 -10
- package/src/components/QueryBuilder.tsx +3 -3
- package/src/components/QueryLoader.tsx +41 -38
- package/src/components/data-cube/QueryBuilderDataCube.tsx +4 -4
- package/src/components/result/QueryBuilderResultPanel.tsx +6 -8
- package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +6 -8
- package/src/index.ts +1 -0
- package/src/stores/QueryBuilderState.ts +13 -9
- package/src/stores/QueryLoaderState.ts +15 -17
- package/src/stores/data-cube/QueryBuilderDataCubeEngine.ts +20 -21
- package/src/stores/data-cube/{QueryBuilderDataCubeEngineHelper.ts → QueryBuilderDataCubeHelper.ts} +13 -9
- package/src/stores/data-cube/QueryBuilderDataCubeViewerState.ts +28 -0
- package/src/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.ts +6 -9
- package/tsconfig.json +2 -1
- package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.d.ts.map +0 -1
- package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.js.map +0 -1
@@ -63,10 +63,10 @@ import {
|
|
63
63
|
ColSpecArrayInstance,
|
64
64
|
ColSpecArray,
|
65
65
|
ColSpec,
|
66
|
-
|
67
|
-
|
66
|
+
RelationType,
|
67
|
+
RelationColumn,
|
68
68
|
getValueSpecificationReturnType,
|
69
|
-
|
69
|
+
Relation,
|
70
70
|
} from '@finos/legend-graph';
|
71
71
|
import {
|
72
72
|
QUERY_BUILDER_PURE_PATH,
|
@@ -663,7 +663,7 @@ const V1_buildTypedProjectFunctionExpression = (
|
|
663
663
|
const processedExpression = new ColSpecArrayInstance(Multiplicity.ONE);
|
664
664
|
const processedColSpecArray = new ColSpecArray();
|
665
665
|
processedExpression.values = [processedColSpecArray];
|
666
|
-
const relationType = new
|
666
|
+
const relationType = new RelationType(RelationType.ID);
|
667
667
|
processedColSpecArray.colSpecs = specArray.colSpecs.map((colSpec) => {
|
668
668
|
const pColSpec = new ColSpec();
|
669
669
|
let lambda: ValueSpecification;
|
@@ -691,9 +691,7 @@ const V1_buildTypedProjectFunctionExpression = (
|
|
691
691
|
pColSpec.name = colSpec.name;
|
692
692
|
const returnType = getValueSpecificationReturnType(lambda);
|
693
693
|
if (returnType) {
|
694
|
-
relationType.columns.push(
|
695
|
-
new Relation_RelationalColumn(colSpec.name, returnType),
|
696
|
-
);
|
694
|
+
relationType.columns.push(new RelationColumn(colSpec.name, returnType));
|
697
695
|
} else {
|
698
696
|
throw new UnsupportedOperationError(
|
699
697
|
'Unable to get return type for current lambda',
|
@@ -707,7 +705,7 @@ const V1_buildTypedProjectFunctionExpression = (
|
|
707
705
|
functionName,
|
708
706
|
compileContext,
|
709
707
|
);
|
710
|
-
const relationGenericType = new GenericType(
|
708
|
+
const relationGenericType = new GenericType(Relation.INSTANCE);
|
711
709
|
const relationTypeGenericType = new GenericType(relationType);
|
712
710
|
relationGenericType.typeArguments = [
|
713
711
|
GenericTypeExplicitReference.create(relationTypeGenericType),
|
package/src/index.ts
CHANGED
@@ -133,3 +133,4 @@ export * from './stores/QueryBuilderValueSpecificationHelper.js';
|
|
133
133
|
export * from './stores/filter/QueryBuilderFilterState.js';
|
134
134
|
export * from './stores/filter/QueryBuilderFilterStateBuilder.js';
|
135
135
|
export * from './stores/data-cube/QueryBuilderDataCubeEngine.js';
|
136
|
+
export * from './stores/data-cube/QueryBuilderDataCubeViewerState.js';
|
@@ -112,8 +112,8 @@ import { QueryBuilderChangeHistoryState } from './QueryBuilderChangeHistoryState
|
|
112
112
|
import { type QueryBuilderWorkflowState } from './query-workflow/QueryBuilderWorkFlowState.js';
|
113
113
|
import { type QueryChatState } from './QueryChatState.js';
|
114
114
|
import type { QueryBuilder_LegendApplicationPlugin_Extension } from './QueryBuilder_LegendApplicationPlugin_Extension.js';
|
115
|
-
import
|
116
|
-
import {
|
115
|
+
import { createDataCubeViewerStateFromQueryBuilder } from './data-cube/QueryBuilderDataCubeHelper.js';
|
116
|
+
import type { QueryBuilderDataCubeViewerState } from './data-cube/QueryBuilderDataCubeViewerState.js';
|
117
117
|
|
118
118
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
119
119
|
export interface QueryableSourceInfo {}
|
@@ -166,7 +166,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
166
166
|
isCheckingEntitlments = false;
|
167
167
|
isCalendarEnabled = false;
|
168
168
|
isLocalModeEnabled = false;
|
169
|
-
|
169
|
+
dataCubeViewerState: QueryBuilderDataCubeViewerState | undefined;
|
170
170
|
INTERNAL__enableInitializingDefaultSimpleExpressionValue = false;
|
171
171
|
|
172
172
|
lambdaWriteMode = QUERY_BUILDER_LAMBDA_WRITER_MODE.STANDARD;
|
@@ -219,7 +219,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
219
219
|
queryChatState: observable,
|
220
220
|
isQueryChatOpened: observable,
|
221
221
|
isLocalModeEnabled: observable,
|
222
|
-
|
222
|
+
dataCubeViewerState: observable,
|
223
223
|
getAllFunction: observable,
|
224
224
|
lambdaWriteMode: observable,
|
225
225
|
INTERNAL__enableInitializingDefaultSimpleExpressionValue: observable,
|
@@ -233,7 +233,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
233
233
|
setShowParametersPanel: action,
|
234
234
|
setIsEditingWatermark: action,
|
235
235
|
setIsCalendarEnabled: action,
|
236
|
-
|
236
|
+
setDataCubeViewerState: action,
|
237
237
|
openDataCubeEngine: action,
|
238
238
|
setIsCheckingEntitlments: action,
|
239
239
|
setClass: action,
|
@@ -417,8 +417,10 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
417
417
|
this.isLocalModeEnabled = val;
|
418
418
|
}
|
419
419
|
|
420
|
-
|
421
|
-
|
420
|
+
setDataCubeViewerState(
|
421
|
+
val: QueryBuilderDataCubeViewerState | undefined,
|
422
|
+
): void {
|
423
|
+
this.dataCubeViewerState = val;
|
422
424
|
}
|
423
425
|
|
424
426
|
setInternalize(val: QueryBuilderInternalizeState | undefined): void {
|
@@ -471,9 +473,11 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
471
473
|
return !this.unsupportedQueryState.rawLambda;
|
472
474
|
}
|
473
475
|
|
474
|
-
openDataCubeEngine()
|
476
|
+
async openDataCubeEngine() {
|
475
477
|
try {
|
476
|
-
this.
|
478
|
+
this.setDataCubeViewerState(
|
479
|
+
await createDataCubeViewerStateFromQueryBuilder(this),
|
480
|
+
);
|
477
481
|
} catch (error) {
|
478
482
|
assertErrorThrown(error);
|
479
483
|
this.applicationStore.notificationService.notifyError(
|
@@ -21,7 +21,7 @@ import {
|
|
21
21
|
import {
|
22
22
|
type QueryInfo,
|
23
23
|
type LightQuery,
|
24
|
-
type
|
24
|
+
type AbstractPureGraphManager,
|
25
25
|
type Query,
|
26
26
|
type RawLambda,
|
27
27
|
QuerySearchSpecification,
|
@@ -56,7 +56,7 @@ export type SortByOption = { label: SORT_BY_OPTIONS; value: SORT_BY_OPTIONS };
|
|
56
56
|
|
57
57
|
export class QueryLoaderState {
|
58
58
|
readonly applicationStore: GenericLegendApplicationStore;
|
59
|
-
readonly
|
59
|
+
readonly graphManager: AbstractPureGraphManager;
|
60
60
|
|
61
61
|
readonly searchQueriesState = ActionState.create();
|
62
62
|
readonly renameQueryState = ActionState.create();
|
@@ -86,7 +86,7 @@ export class QueryLoaderState {
|
|
86
86
|
extraFilterOptions: LoadQueryFilterOption[] = [];
|
87
87
|
extraQueryFilterOptionsRelatedToTemplateQuery: string[] = [];
|
88
88
|
queries: LightQuery[] = [];
|
89
|
-
|
89
|
+
curatedTemplateQuerySpecifications: CuratedTemplateQuerySpecification[] = [];
|
90
90
|
|
91
91
|
isQueryLoaderDialogOpen = false;
|
92
92
|
isCuratedTemplateToggled = false;
|
@@ -97,7 +97,7 @@ export class QueryLoaderState {
|
|
97
97
|
|
98
98
|
constructor(
|
99
99
|
applicationStore: GenericLegendApplicationStore,
|
100
|
-
|
100
|
+
graphManager: AbstractPureGraphManager,
|
101
101
|
options: {
|
102
102
|
decorateSearchSpecification?:
|
103
103
|
| ((val: QuerySearchSpecification) => QuerySearchSpecification)
|
@@ -108,7 +108,6 @@ export class QueryLoaderState {
|
|
108
108
|
generateDefaultQueriesSummaryText?:
|
109
109
|
| ((queries: LightQuery[]) => string)
|
110
110
|
| undefined;
|
111
|
-
|
112
111
|
isReadOnly?: boolean | undefined;
|
113
112
|
onQueryRenamed?: ((query: LightQuery) => void) | undefined;
|
114
113
|
onQueryDeleted?: ((query: string) => void) | undefined;
|
@@ -124,7 +123,7 @@ export class QueryLoaderState {
|
|
124
123
|
showPreviewViewer: observable,
|
125
124
|
searchText: observable,
|
126
125
|
isCuratedTemplateToggled: observable,
|
127
|
-
|
126
|
+
curatedTemplateQuerySpecifications: observable,
|
128
127
|
sortBy: observable,
|
129
128
|
setSortBy: action,
|
130
129
|
setSearchText: action,
|
@@ -141,7 +140,7 @@ export class QueryLoaderState {
|
|
141
140
|
});
|
142
141
|
|
143
142
|
this.applicationStore = applicationStore;
|
144
|
-
this.
|
143
|
+
this.graphManager = graphManager;
|
145
144
|
|
146
145
|
this.loadQuery = options.loadQuery;
|
147
146
|
this.fetchDefaultQueries = options.fetchDefaultQueries;
|
@@ -237,7 +236,7 @@ export class QueryLoaderState {
|
|
237
236
|
extraFilters.forEach(
|
238
237
|
(filter) => filter && this.extraFilters.set(filter, false),
|
239
238
|
);
|
240
|
-
this.
|
239
|
+
this.curatedTemplateQuerySpecifications =
|
241
240
|
this.applicationStore.pluginManager
|
242
241
|
.getApplicationPlugins()
|
243
242
|
.flatMap(
|
@@ -311,7 +310,7 @@ export class QueryLoaderState {
|
|
311
310
|
searchSpecification =
|
312
311
|
this.decorateSearchSpecification?.(searchSpecification) ??
|
313
312
|
searchSpecification;
|
314
|
-
this.queries = (yield this.
|
313
|
+
this.queries = (yield this.graphManager.searchQueries(
|
315
314
|
searchSpecification,
|
316
315
|
)) as LightQuery[];
|
317
316
|
if (!querySearchSortBy) {
|
@@ -330,7 +329,7 @@ export class QueryLoaderState {
|
|
330
329
|
*renameQuery(queryId: string, name: string): GeneratorFn<void> {
|
331
330
|
this.renameQueryState.inProgress();
|
332
331
|
try {
|
333
|
-
const query = (yield this.
|
332
|
+
const query = (yield this.graphManager.renameQuery(
|
334
333
|
queryId,
|
335
334
|
name,
|
336
335
|
)) as Query;
|
@@ -350,7 +349,7 @@ export class QueryLoaderState {
|
|
350
349
|
*deleteQuery(queryId: string): GeneratorFn<void> {
|
351
350
|
this.deleteQueryState.inProgress();
|
352
351
|
try {
|
353
|
-
yield this.
|
352
|
+
yield this.graphManager.deleteQuery(queryId);
|
354
353
|
this.onQueryDeleted?.(queryId);
|
355
354
|
this.applicationStore.notificationService.notifySuccess(
|
356
355
|
'Deleted query successfully',
|
@@ -374,13 +373,12 @@ export class QueryLoaderState {
|
|
374
373
|
this.previewQueryState.inProgress();
|
375
374
|
try {
|
376
375
|
if (queryId) {
|
377
|
-
const queryInfo =
|
378
|
-
|
379
|
-
|
380
|
-
)) as QueryInfo;
|
376
|
+
const queryInfo = (yield this.graphManager.getQueryInfo(
|
377
|
+
queryId,
|
378
|
+
)) as QueryInfo;
|
381
379
|
this.queryPreviewContent = queryInfo;
|
382
380
|
this.queryPreviewContent.content =
|
383
|
-
(yield this.
|
381
|
+
(yield this.graphManager.prettyLambdaContent(
|
384
382
|
queryInfo.content,
|
385
383
|
)) as string;
|
386
384
|
} else if (template) {
|
@@ -389,7 +387,7 @@ export class QueryLoaderState {
|
|
389
387
|
content: '',
|
390
388
|
} as QueryInfo;
|
391
389
|
this.queryPreviewContent.content =
|
392
|
-
(yield this.
|
390
|
+
(yield this.graphManager.lambdaToPureCode(
|
393
391
|
template.queryContent,
|
394
392
|
true,
|
395
393
|
)) as string;
|
@@ -15,12 +15,11 @@
|
|
15
15
|
*/
|
16
16
|
|
17
17
|
import {
|
18
|
-
SUPPORTED_FUNCTIONS,
|
19
|
-
V1_AppliedFunction,
|
20
18
|
V1_Lambda,
|
21
19
|
RawLambda,
|
22
20
|
RelationalExecutionActivities,
|
23
21
|
TDSExecutionResult,
|
22
|
+
V1_AppliedFunction,
|
24
23
|
V1_deserializeRawValueSpecification,
|
25
24
|
V1_deserializeValueSpecification,
|
26
25
|
V1_RawLambda,
|
@@ -30,17 +29,17 @@ import {
|
|
30
29
|
type V1_ValueSpecification,
|
31
30
|
type ParameterValue,
|
32
31
|
LAMBDA_PIPE,
|
32
|
+
SUPPORTED_FUNCTIONS,
|
33
33
|
} from '@finos/legend-graph';
|
34
34
|
import {
|
35
35
|
_elementPtr,
|
36
|
-
_functionName,
|
37
36
|
DataCubeEngine,
|
38
37
|
DataCubeSource,
|
39
|
-
type RelationType,
|
40
|
-
DataCubeQuery,
|
41
|
-
type CompletionItem,
|
42
38
|
_function,
|
43
39
|
DataCubeFunction,
|
40
|
+
type CompletionItem,
|
41
|
+
_functionName,
|
42
|
+
DataCubeQuery,
|
44
43
|
} from '@finos/legend-data-cube';
|
45
44
|
import {
|
46
45
|
guaranteeType,
|
@@ -61,7 +60,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
61
60
|
readonly mappingPath: string | undefined;
|
62
61
|
readonly parameterValues: ParameterValue[] | undefined;
|
63
62
|
readonly runtimePath: string | undefined;
|
64
|
-
|
63
|
+
readonly parameters: object | undefined;
|
65
64
|
|
66
65
|
constructor(
|
67
66
|
selectQuery: RawLambda,
|
@@ -71,11 +70,13 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
71
70
|
graphManagerState: GraphManagerState,
|
72
71
|
) {
|
73
72
|
super();
|
73
|
+
|
74
74
|
this.graphState = graphManagerState;
|
75
75
|
this.selectInitialQuery = selectQuery;
|
76
76
|
this.mappingPath = mappingPath;
|
77
77
|
this.runtimePath = runtimePath;
|
78
78
|
this.parameterValues = parameterValues;
|
79
|
+
this.parameters = selectQuery.parameters;
|
79
80
|
}
|
80
81
|
|
81
82
|
get sourceLabel(): string {
|
@@ -105,9 +106,8 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
105
106
|
return srcFuncExp;
|
106
107
|
}
|
107
108
|
|
108
|
-
async
|
109
|
+
async generateInitialQuery() {
|
109
110
|
const srcFuncExp = this.getSourceFunctionExpression();
|
110
|
-
this._parameters = this.selectInitialQuery.parameters;
|
111
111
|
const fromFuncExp = new V1_AppliedFunction();
|
112
112
|
fromFuncExp.function = _functionName(SUPPORTED_FUNCTIONS.FROM);
|
113
113
|
fromFuncExp.parameters = [srcFuncExp];
|
@@ -117,18 +117,22 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
117
117
|
if (this.runtimePath) {
|
118
118
|
fromFuncExp.parameters.push(_elementPtr(this.runtimePath));
|
119
119
|
}
|
120
|
-
const columns = (await this.
|
120
|
+
const columns = (await this.getRelationType(this.selectInitialQuery))
|
121
121
|
.columns;
|
122
122
|
const query = new DataCubeQuery();
|
123
123
|
query.query = `~[${columns.map((e) => `'${e.name}'`)}]->select()`;
|
124
|
+
|
124
125
|
return query;
|
125
126
|
}
|
126
127
|
|
127
128
|
async processQuerySource(value: PlainObject) {
|
129
|
+
// TODO: this is an abnormal usage of this method, this is the place
|
130
|
+
// where we can enforce which source this engine supports, instead
|
131
|
+
// of hardcoding the logic like this.
|
128
132
|
const srcFuncExp = this.getSourceFunctionExpression();
|
129
133
|
const source = new QueryBuilderDataCubeSource();
|
130
|
-
source.
|
131
|
-
await this.
|
134
|
+
source.columns = (
|
135
|
+
await this.getRelationType(this.selectInitialQuery)
|
132
136
|
).columns;
|
133
137
|
source.mapping = this.mappingPath;
|
134
138
|
source.runtime = this.runtimePath;
|
@@ -181,7 +185,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
181
185
|
);
|
182
186
|
}
|
183
187
|
|
184
|
-
async getValueSpecificationCode(
|
188
|
+
override async getValueSpecificationCode(
|
185
189
|
value: V1_ValueSpecification,
|
186
190
|
pretty?: boolean | undefined,
|
187
191
|
) {
|
@@ -191,7 +195,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
191
195
|
);
|
192
196
|
}
|
193
197
|
|
194
|
-
async
|
198
|
+
async getRelationType(query: RawLambda) {
|
195
199
|
const relationType =
|
196
200
|
await this.graphState.graphManager.getLambdaRelationType(
|
197
201
|
query,
|
@@ -200,11 +204,6 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
200
204
|
return relationType;
|
201
205
|
}
|
202
206
|
|
203
|
-
async getQueryRelationType(query: V1_Lambda, source: DataCubeSource) {
|
204
|
-
const lambda = this.buildRawLambdaFromValueSpec(query);
|
205
|
-
return this.getRelationalType(lambda);
|
206
|
-
}
|
207
|
-
|
208
207
|
override async getQueryCodeRelationReturnType(
|
209
208
|
code: string,
|
210
209
|
baseQuery: V1_ValueSpecification,
|
@@ -215,14 +214,14 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
215
214
|
V1_serializeValueSpecification(baseQuery, []),
|
216
215
|
);
|
217
216
|
const fullQuery = queryString + code;
|
218
|
-
return this.
|
217
|
+
return this.getRelationType(
|
219
218
|
await this.graphState.graphManager.pureCodeToLambda(fullQuery),
|
220
219
|
);
|
221
220
|
}
|
222
221
|
|
223
222
|
override async executeQuery(query: V1_Lambda, source: DataCubeSource) {
|
224
223
|
const lambda = this.buildRawLambdaFromValueSpec(query);
|
225
|
-
lambda.parameters = this.
|
224
|
+
lambda.parameters = this.parameters;
|
226
225
|
const [executionWithMetadata, queryString] = await Promise.all([
|
227
226
|
this.graphState.graphManager.runQuery(
|
228
227
|
lambda,
|
package/src/stores/data-cube/{QueryBuilderDataCubeEngineHelper.ts → QueryBuilderDataCubeHelper.ts}
RENAMED
@@ -21,19 +21,21 @@ import {
|
|
21
21
|
import { RuntimePointer } from '@finos/legend-graph';
|
22
22
|
import { QueryBuilderDataCubeEngine } from './QueryBuilderDataCubeEngine.js';
|
23
23
|
import { buildExecutionParameterValues } from '../shared/LambdaParameterState.js';
|
24
|
+
import { QueryBuilderDataCubeViewerState } from './QueryBuilderDataCubeViewerState.js';
|
24
25
|
|
25
|
-
export const
|
26
|
+
export const createDataCubeViewerStateFromQueryBuilder = async (
|
26
27
|
queryBuilderState: QueryBuilderState,
|
27
|
-
):
|
28
|
-
const
|
28
|
+
): Promise<QueryBuilderDataCubeViewerState | undefined> => {
|
29
|
+
const runtimePath =
|
29
30
|
queryBuilderState.executionContextState.runtimeValue instanceof
|
30
31
|
RuntimePointer
|
31
32
|
? queryBuilderState.executionContextState.runtimeValue.packageableRuntime
|
32
33
|
.value.path
|
33
34
|
: undefined;
|
34
|
-
if (!
|
35
|
+
if (!runtimePath) {
|
35
36
|
return undefined;
|
36
37
|
}
|
38
|
+
const mappingPath = queryBuilderState.executionContextState.mapping?.path;
|
37
39
|
const currentLambdaWriterMode = queryBuilderState.lambdaWriteMode;
|
38
40
|
// ensure we write in new tds mode
|
39
41
|
queryBuilderState.setLambdaWriteMode(
|
@@ -43,13 +45,15 @@ export const createDataCubeEngineFromQueryBuilder = (
|
|
43
45
|
queryBuilderState.parametersState.parameterStates,
|
44
46
|
queryBuilderState.graphManagerState,
|
45
47
|
);
|
46
|
-
const
|
47
|
-
|
48
|
+
const lambda = queryBuilderState.buildQuery();
|
49
|
+
const engine = new QueryBuilderDataCubeEngine(
|
50
|
+
lambda,
|
48
51
|
parameterValues,
|
49
|
-
|
50
|
-
|
52
|
+
mappingPath,
|
53
|
+
runtimePath,
|
51
54
|
queryBuilderState.graphManagerState,
|
52
55
|
);
|
53
56
|
queryBuilderState.setLambdaWriteMode(currentLambdaWriterMode);
|
54
|
-
|
57
|
+
const query = await engine.generateInitialQuery();
|
58
|
+
return new QueryBuilderDataCubeViewerState(query, engine);
|
55
59
|
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import type { DataCubeQuery } from '@finos/legend-data-cube';
|
18
|
+
import type { QueryBuilderDataCubeEngine } from './QueryBuilderDataCubeEngine.js';
|
19
|
+
|
20
|
+
export class QueryBuilderDataCubeViewerState {
|
21
|
+
query: DataCubeQuery;
|
22
|
+
engine: QueryBuilderDataCubeEngine;
|
23
|
+
|
24
|
+
constructor(query: DataCubeQuery, engine: QueryBuilderDataCubeEngine) {
|
25
|
+
this.query = query;
|
26
|
+
this.engine = engine;
|
27
|
+
}
|
28
|
+
}
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.ts
CHANGED
@@ -28,9 +28,9 @@ import {
|
|
28
28
|
V1_GraphTransformerContextBuilder,
|
29
29
|
GenericType,
|
30
30
|
GenericTypeExplicitReference,
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
Relation,
|
32
|
+
RelationColumn,
|
33
|
+
RelationType,
|
34
34
|
} from '@finos/legend-graph';
|
35
35
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graph/QueryBuilderMetaModelConst.js';
|
36
36
|
import {
|
@@ -64,7 +64,7 @@ export const buildRelationProjection = (
|
|
64
64
|
|
65
65
|
const colSepcArray = new ColSpecArray();
|
66
66
|
instanceVal.values = [colSepcArray];
|
67
|
-
const relationType = new
|
67
|
+
const relationType = new RelationType(RelationType.ID);
|
68
68
|
|
69
69
|
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
70
70
|
const colSpec = new ColSpec();
|
@@ -118,14 +118,11 @@ export const buildRelationProjection = (
|
|
118
118
|
`Can't create value spec for projection column ${projectionColumnState.columnName}`,
|
119
119
|
);
|
120
120
|
relationType.columns.push(
|
121
|
-
new
|
122
|
-
projectionColumnState.columnName,
|
123
|
-
returnType,
|
124
|
-
),
|
121
|
+
new RelationColumn(projectionColumnState.columnName, returnType),
|
125
122
|
);
|
126
123
|
});
|
127
124
|
projectFunction.parametersValues = [precedingExpression, instanceVal];
|
128
|
-
const relationGenericType = new GenericType(
|
125
|
+
const relationGenericType = new GenericType(Relation.INSTANCE);
|
129
126
|
const relationTypeGenericType = new GenericType(relationType);
|
130
127
|
relationGenericType.typeArguments = [
|
131
128
|
GenericTypeExplicitReference.create(relationTypeGenericType),
|
package/tsconfig.json
CHANGED
@@ -103,7 +103,8 @@
|
|
103
103
|
"./src/stores/__test-utils__/QueryBuilderStateTestUtils.ts",
|
104
104
|
"./src/stores/data-access/DataAccessState.ts",
|
105
105
|
"./src/stores/data-cube/QueryBuilderDataCubeEngine.ts",
|
106
|
-
"./src/stores/data-cube/
|
106
|
+
"./src/stores/data-cube/QueryBuilderDataCubeHelper.ts",
|
107
|
+
"./src/stores/data-cube/QueryBuilderDataCubeViewerState.ts",
|
107
108
|
"./src/stores/entitlements/QueryBuilderCheckEntitlementsState.ts",
|
108
109
|
"./src/stores/execution-plan/ExecutionPlanState.ts",
|
109
110
|
"./src/stores/explorer/QueryBuilderExplorerState.ts",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderDataCubeEngineHelper.d.ts","sourceRoot":"","sources":["../../../src/stores/data-cube/QueryBuilderDataCubeEngineHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAG7E,eAAO,MAAM,oCAAoC,sBAC5B,iBAAiB,KACnC,0BAA0B,GAAG,SA4B/B,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderDataCubeEngineHelper.js","sourceRoot":"","sources":["../../../src/stores/data-cube/QueryBuilderDataCubeEngineHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,gCAAgC,GAEjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAElF,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAClD,iBAAoC,EACI,EAAE;IAC1C,MAAM,OAAO,GACX,iBAAiB,CAAC,qBAAqB,CAAC,YAAY;QACpD,cAAc;QACZ,CAAC,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,YAAY,CAAC,kBAAkB;aACpE,KAAK,CAAC,IAAI;QACf,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,eAAe,CAAC;IAClE,kCAAkC;IAClC,iBAAiB,CAAC,kBAAkB,CAClC,gCAAgC,CAAC,qBAAqB,CACvD,CAAC;IACF,MAAM,eAAe,GAAG,6BAA6B,CACnD,iBAAiB,CAAC,eAAe,CAAC,eAAe,EACjD,iBAAiB,CAAC,iBAAiB,CACpC,CAAC;IACF,MAAM,kBAAkB,GAAG,IAAI,0BAA0B,CACvD,iBAAiB,CAAC,UAAU,EAAE,EAC9B,eAAe,EACf,iBAAiB,CAAC,qBAAqB,CAAC,OAAO,EAAE,IAAI,EACrD,OAAO,EACP,iBAAiB,CAAC,iBAAiB,CACpC,CAAC;IACF,iBAAiB,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;IAC9D,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC"}
|