@finos/legend-query-builder 4.14.30 → 4.14.31
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilder.d.ts +1 -1
- package/lib/components/QueryBuilder.d.ts.map +1 -1
- package/lib/components/QueryBuilder.js +36 -3
- package/lib/components/QueryBuilder.js.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js +5 -10
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts +3 -0
- package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.js +5 -0
- package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +4 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +51 -3
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
- package/lib/index.css +17 -1
- 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 +1 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +1 -0
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts +4 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +12 -1
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts +2 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.js +33 -4
- package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts +5 -0
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js +1 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +1 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.d.ts +2 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js +7 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +1 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +4 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.d.ts +2 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.d.ts.map +1 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.js +2 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.js.map +1 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +1 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +4 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts +4 -3
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +35 -3
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts +2 -9
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +45 -36
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
- package/{src/stores/workflow/QueryBuilderWorkFlowState.ts → lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.d.ts} +5 -12
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.d.ts.map +1 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.js +55 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.js.map +1 -0
- package/lib/stores/{workflow → query-workflow}/QueryBuilderWorkFlowState.d.ts +12 -0
- package/lib/stores/query-workflow/QueryBuilderWorkFlowState.d.ts.map +1 -0
- package/lib/stores/{workflow → query-workflow}/QueryBuilderWorkFlowState.js +18 -0
- package/lib/stores/query-workflow/QueryBuilderWorkFlowState.js.map +1 -0
- package/lib/stores/workflows/FunctionQueryBuilderState.d.ts +1 -1
- package/lib/stores/workflows/FunctionQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/MappingQueryBuilderState.d.ts +1 -1
- package/lib/stores/workflows/MappingQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/ServiceQueryBuilderState.d.ts +1 -1
- package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/QueryBuilder.tsx +77 -2
- package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +1 -1
- package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +29 -29
- package/src/graph/QueryBuilderMetaModelConst.ts +7 -0
- package/src/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +3 -3
- package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +122 -1
- package/src/index.ts +1 -1
- package/src/stores/QueryBuilderResultState.ts +1 -0
- package/src/stores/QueryBuilderState.ts +17 -1
- package/src/stores/QueryBuilderStateBuilder.ts +65 -5
- package/src/stores/QueryBuilderValueSpecificationBuilderHelper.ts +5 -0
- package/src/stores/__test-utils__/QueryBuilderStateTestUtils.ts +1 -1
- package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +1 -0
- package/src/stores/fetch-structure/QueryBuilderFetchStructureState.ts +15 -0
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +5 -0
- package/src/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.ts +0 -0
- package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +5 -0
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +76 -2
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +90 -81
- package/src/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.ts +108 -0
- package/src/stores/query-workflow/QueryBuilderWorkFlowState.ts +64 -0
- package/src/stores/workflows/FunctionQueryBuilderState.ts +1 -1
- package/src/stores/workflows/MappingQueryBuilderState.ts +1 -1
- package/src/stores/workflows/ServiceQueryBuilderState.ts +1 -1
- package/tsconfig.json +3 -1
- package/lib/stores/workflow/QueryBuilderWorkFlowState.d.ts.map +0 -1
- package/lib/stores/workflow/QueryBuilderWorkFlowState.js.map +0 -1
@@ -28,6 +28,7 @@ import {
|
|
28
28
|
V1_RawLambda,
|
29
29
|
VariableExpression,
|
30
30
|
PrimitiveInstanceValue,
|
31
|
+
ColSpecArrayInstance,
|
31
32
|
} from '@finos/legend-graph';
|
32
33
|
import {
|
33
34
|
assertNonNullable,
|
@@ -44,7 +45,10 @@ import {
|
|
44
45
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
45
46
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
46
47
|
} from '../../../../graph/QueryBuilderMetaModelConst.js';
|
47
|
-
import
|
48
|
+
import {
|
49
|
+
QUERY_BUILDER_LAMBDA_WRITER_MODE,
|
50
|
+
type QueryBuilderState,
|
51
|
+
} from '../../../QueryBuilderState.js';
|
48
52
|
import { QueryBuilderValueSpecificationProcessor } from '../../../QueryBuilderStateBuilder.js';
|
49
53
|
import {
|
50
54
|
extractNullableNumberFromInstanceValue,
|
@@ -59,11 +63,74 @@ import {
|
|
59
63
|
import { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
60
64
|
import { SortColumnState } from '../QueryResultSetModifierState.js';
|
61
65
|
|
66
|
+
export const processTypedTDSProjectExpression = (
|
67
|
+
expression: SimpleFunctionExpression,
|
68
|
+
queryBuilderState: QueryBuilderState,
|
69
|
+
parentLambda: LambdaFunction,
|
70
|
+
): void => {
|
71
|
+
// check parameters
|
72
|
+
assertTrue(
|
73
|
+
expression.parametersValues.length === 2,
|
74
|
+
`Can't process project() expression: project() expects 2 arguments`,
|
75
|
+
);
|
76
|
+
// update fetch-structure
|
77
|
+
queryBuilderState.fetchStructureState.changeImplementation(
|
78
|
+
FETCH_STRUCTURE_IMPLEMENTATION.TABULAR_DATA_STRUCTURE,
|
79
|
+
);
|
80
|
+
|
81
|
+
// check preceding expression
|
82
|
+
const precedingExpression = guaranteeType(
|
83
|
+
expression.parametersValues[0],
|
84
|
+
SimpleFunctionExpression,
|
85
|
+
`Can't process project() expression: only support project() immediately following an expression`,
|
86
|
+
);
|
87
|
+
assertTrue(
|
88
|
+
matchFunctionName(precedingExpression.functionName, [
|
89
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
90
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
91
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
92
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
93
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
|
94
|
+
]),
|
95
|
+
`Can't process project() expression: only support project() immediately following either getAll(), filter(), or forWatermark()`,
|
96
|
+
);
|
97
|
+
QueryBuilderValueSpecificationProcessor.process(
|
98
|
+
precedingExpression,
|
99
|
+
parentLambda,
|
100
|
+
queryBuilderState,
|
101
|
+
);
|
102
|
+
// check columns
|
103
|
+
const classInstance = expression.parametersValues[1];
|
104
|
+
assertType(
|
105
|
+
classInstance,
|
106
|
+
ColSpecArrayInstance,
|
107
|
+
`Can't process project() expression: project() expects argument #1 to be a ColSpecArrayInstance`,
|
108
|
+
);
|
109
|
+
queryBuilderState.setLambdaWriteMode(
|
110
|
+
QUERY_BUILDER_LAMBDA_WRITER_MODE.TYPED_FETCH_STRUCTURE,
|
111
|
+
);
|
112
|
+
QueryBuilderValueSpecificationProcessor.processChild(
|
113
|
+
classInstance,
|
114
|
+
expression,
|
115
|
+
parentLambda,
|
116
|
+
queryBuilderState,
|
117
|
+
);
|
118
|
+
};
|
119
|
+
|
62
120
|
export const processTDSProjectExpression = (
|
63
121
|
expression: SimpleFunctionExpression,
|
64
122
|
queryBuilderState: QueryBuilderState,
|
65
123
|
parentLambda: LambdaFunction,
|
66
124
|
): void => {
|
125
|
+
if (expression.parametersValues.length === 2) {
|
126
|
+
processTypedTDSProjectExpression(
|
127
|
+
expression,
|
128
|
+
queryBuilderState,
|
129
|
+
parentLambda,
|
130
|
+
);
|
131
|
+
|
132
|
+
return;
|
133
|
+
}
|
67
134
|
// update fetch-structure
|
68
135
|
queryBuilderState.fetchStructureState.changeImplementation(
|
69
136
|
FETCH_STRUCTURE_IMPLEMENTATION.TABULAR_DATA_STRUCTURE,
|
@@ -142,6 +209,7 @@ export const processTDSProjectExpression = (
|
|
142
209
|
|
143
210
|
export const processTDSProjectionColumnPropertyExpression = (
|
144
211
|
expression: AbstractPropertyExpression,
|
212
|
+
columnName: string | undefined,
|
145
213
|
queryBuilderState: QueryBuilderState,
|
146
214
|
): void => {
|
147
215
|
if (
|
@@ -200,7 +268,9 @@ export const processTDSProjectionColumnPropertyExpression = (
|
|
200
268
|
);
|
201
269
|
|
202
270
|
tdsState.addColumn(columnState, { skipSorting: true });
|
203
|
-
|
271
|
+
if (columnName) {
|
272
|
+
columnState.setColumnName(columnName);
|
273
|
+
}
|
204
274
|
// NOTE: technically we should set the lambda parameter name when we process
|
205
275
|
// the lambda, not when we process the lambda body like this, but that requires
|
206
276
|
// some setup, so it's easier to do it here. The validation of this should have
|
@@ -211,6 +281,7 @@ export const processTDSProjectionColumnPropertyExpression = (
|
|
211
281
|
|
212
282
|
export const processTDSProjectionDerivationExpression = (
|
213
283
|
value: INTERNAL__UnknownValueSpecification,
|
284
|
+
columnName: string | undefined,
|
214
285
|
parentExpression: SimpleFunctionExpression,
|
215
286
|
queryBuilderState: QueryBuilderState,
|
216
287
|
): void => {
|
@@ -236,6 +307,9 @@ export const processTDSProjectionDerivationExpression = (
|
|
236
307
|
new RawLambda(rawLambdaProtocol.parameters, rawLambdaProtocol.body),
|
237
308
|
);
|
238
309
|
projectionState.addColumn(columnState, { skipSorting: true });
|
310
|
+
if (columnName) {
|
311
|
+
columnState.setColumnName(columnName);
|
312
|
+
}
|
239
313
|
}
|
240
314
|
};
|
241
315
|
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts
CHANGED
@@ -45,10 +45,14 @@ import {
|
|
45
45
|
} from '../QueryResultSetModifierState.js';
|
46
46
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graph/QueryBuilderMetaModelConst.js';
|
47
47
|
import { buildGenericLambdaFunctionInstanceValue } from '../../../QueryBuilderValueSpecificationHelper.js';
|
48
|
-
import {
|
48
|
+
import {
|
49
|
+
buildPropertyExpressionChain,
|
50
|
+
type LambdaFunctionBuilderOption,
|
51
|
+
} from '../../../QueryBuilderValueSpecificationBuilderHelper.js';
|
49
52
|
import { appendOLAPGroupByState } from '../window/QueryBuilderWindowValueSpecificationBuilder.js';
|
50
53
|
import { appendPostFilter } from '../post-filter/QueryBuilderPostFilterValueSpecificationBuilder.js';
|
51
54
|
import { buildTDSSortTypeExpression } from '../QueryBuilderTDSHelper.js';
|
55
|
+
import { buildRelationProjection } from './QueryBuilderRelationProjectValueSpecBuidler.js';
|
52
56
|
|
53
57
|
const buildSortExpression = (
|
54
58
|
sortColumnState: SortColumnState,
|
@@ -174,15 +178,7 @@ const appendResultSetModifier = (
|
|
174
178
|
export const appendProjection = (
|
175
179
|
tdsState: QueryBuilderTDSState,
|
176
180
|
lambdaFunction: LambdaFunction,
|
177
|
-
options?:
|
178
|
-
/**
|
179
|
-
* Set queryBuilderState to `true` when we construct query for execution within the app.
|
180
|
-
* queryBuilderState will make the lambda function building process overrides several query values, such as the row limit.
|
181
|
-
*/
|
182
|
-
isBuildingExecutionQuery?: boolean | undefined;
|
183
|
-
keepSourceInformation?: boolean | undefined;
|
184
|
-
isExportingResult?: boolean | undefined;
|
185
|
-
},
|
181
|
+
options?: LambdaFunctionBuilderOption,
|
186
182
|
): void => {
|
187
183
|
const queryBuilderState = tdsState.queryBuilderState;
|
188
184
|
const precedingExpression = guaranteeNonNullable(
|
@@ -327,82 +323,95 @@ export const appendProjection = (
|
|
327
323
|
];
|
328
324
|
lambdaFunction.expressionSequence[0] = groupByFunction;
|
329
325
|
} else if (tdsState.projectionColumns.length) {
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
336
|
-
tdsState.projectionColumns.length,
|
337
|
-
tdsState.projectionColumns.length,
|
338
|
-
),
|
339
|
-
);
|
340
|
-
const colAliases = new CollectionInstanceValue(
|
341
|
-
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
342
|
-
tdsState.projectionColumns.length,
|
343
|
-
tdsState.projectionColumns.length,
|
344
|
-
),
|
345
|
-
);
|
346
|
-
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
347
|
-
// column alias
|
348
|
-
const colAlias = new PrimitiveInstanceValue(
|
349
|
-
GenericTypeExplicitReference.create(
|
350
|
-
new GenericType(PrimitiveType.STRING),
|
326
|
+
if (!tdsState.queryBuilderState.isFetchStructureTyped) {
|
327
|
+
// projection
|
328
|
+
const projectFunction = new SimpleFunctionExpression(
|
329
|
+
extractElementNameFromPath(
|
330
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
351
331
|
),
|
352
332
|
);
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
),
|
370
|
-
|
371
|
-
queryBuilderState.graphManagerState.graph,
|
333
|
+
const colLambdas = new CollectionInstanceValue(
|
334
|
+
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
335
|
+
tdsState.projectionColumns.length,
|
336
|
+
tdsState.projectionColumns.length,
|
337
|
+
),
|
338
|
+
);
|
339
|
+
const colAliases = new CollectionInstanceValue(
|
340
|
+
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
341
|
+
tdsState.projectionColumns.length,
|
342
|
+
tdsState.projectionColumns.length,
|
343
|
+
),
|
344
|
+
);
|
345
|
+
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
346
|
+
// column alias
|
347
|
+
const colAlias = new PrimitiveInstanceValue(
|
348
|
+
GenericTypeExplicitReference.create(
|
349
|
+
new GenericType(PrimitiveType.STRING),
|
350
|
+
),
|
372
351
|
);
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
columnLambda
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
352
|
+
colAlias.values.push(projectionColumnState.columnName);
|
353
|
+
colAliases.values.push(colAlias);
|
354
|
+
|
355
|
+
// column projection
|
356
|
+
let columnLambda: ValueSpecification;
|
357
|
+
if (
|
358
|
+
projectionColumnState instanceof
|
359
|
+
QueryBuilderSimpleProjectionColumnState
|
360
|
+
) {
|
361
|
+
columnLambda = buildGenericLambdaFunctionInstanceValue(
|
362
|
+
projectionColumnState.lambdaParameterName,
|
363
|
+
[
|
364
|
+
buildPropertyExpressionChain(
|
365
|
+
projectionColumnState.propertyExpressionState
|
366
|
+
.propertyExpression,
|
367
|
+
projectionColumnState.propertyExpressionState.queryBuilderState,
|
368
|
+
projectionColumnState.lambdaParameterName,
|
369
|
+
options,
|
370
|
+
),
|
371
|
+
],
|
372
|
+
queryBuilderState.graphManagerState.graph,
|
373
|
+
);
|
374
|
+
} else if (
|
375
|
+
projectionColumnState instanceof
|
376
|
+
QueryBuilderDerivationProjectionColumnState
|
377
|
+
) {
|
378
|
+
columnLambda = new INTERNAL__UnknownValueSpecification(
|
379
|
+
V1_serializeRawValueSpecification(
|
380
|
+
V1_transformRawLambda(
|
381
|
+
projectionColumnState.lambda,
|
382
|
+
new V1_GraphTransformerContextBuilder(
|
383
|
+
// TODO?: do we need to include the plugins here?
|
384
|
+
[],
|
387
385
|
)
|
388
|
-
|
386
|
+
.withKeepSourceInformationFlag(
|
387
|
+
Boolean(options?.keepSourceInformation),
|
388
|
+
)
|
389
|
+
.build(),
|
390
|
+
),
|
389
391
|
),
|
390
|
-
)
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
392
|
+
);
|
393
|
+
} else {
|
394
|
+
throw new UnsupportedOperationError(
|
395
|
+
`Can't build project() column expression: unsupported projection column state`,
|
396
|
+
projectionColumnState,
|
397
|
+
);
|
398
|
+
}
|
399
|
+
colLambdas.values.push(columnLambda);
|
400
|
+
});
|
401
|
+
projectFunction.parametersValues = [
|
402
|
+
precedingExpression,
|
403
|
+
colLambdas,
|
404
|
+
colAliases,
|
405
|
+
];
|
406
|
+
lambdaFunction.expressionSequence[0] = projectFunction;
|
407
|
+
} else {
|
408
|
+
const projectFunction = buildRelationProjection(
|
409
|
+
precedingExpression,
|
410
|
+
tdsState,
|
411
|
+
options,
|
412
|
+
);
|
413
|
+
lambdaFunction.expressionSequence[0] = projectFunction;
|
414
|
+
}
|
406
415
|
}
|
407
416
|
|
408
417
|
// build olapGroupBy
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.ts
ADDED
@@ -0,0 +1,108 @@
|
|
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
|
+
ColSpecArray,
|
19
|
+
type ValueSpecification,
|
20
|
+
extractElementNameFromPath,
|
21
|
+
SimpleFunctionExpression,
|
22
|
+
ColSpecArrayInstance,
|
23
|
+
Multiplicity,
|
24
|
+
ColSpec,
|
25
|
+
INTERNAL__UnknownValueSpecification,
|
26
|
+
V1_serializeRawValueSpecification,
|
27
|
+
V1_transformRawLambda,
|
28
|
+
V1_GraphTransformerContextBuilder,
|
29
|
+
} from '@finos/legend-graph';
|
30
|
+
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graph/QueryBuilderMetaModelConst.js';
|
31
|
+
import {
|
32
|
+
QueryBuilderDerivationProjectionColumnState,
|
33
|
+
QueryBuilderSimpleProjectionColumnState,
|
34
|
+
} from './QueryBuilderProjectionColumnState.js';
|
35
|
+
import type { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
36
|
+
import { buildGenericLambdaFunctionInstanceValue } from '../../../QueryBuilderValueSpecificationHelper.js';
|
37
|
+
import {
|
38
|
+
buildPropertyExpressionChain,
|
39
|
+
type LambdaFunctionBuilderOption,
|
40
|
+
} from '../../../QueryBuilderValueSpecificationBuilderHelper.js';
|
41
|
+
import { UnsupportedOperationError } from '@finos/legend-shared';
|
42
|
+
|
43
|
+
export const buildRelationProjection = (
|
44
|
+
precedingExpression: ValueSpecification,
|
45
|
+
tdsState: QueryBuilderTDSState,
|
46
|
+
options?: LambdaFunctionBuilderOption,
|
47
|
+
): SimpleFunctionExpression => {
|
48
|
+
const projectFunction = new SimpleFunctionExpression(
|
49
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT),
|
50
|
+
);
|
51
|
+
const queryBuilderState = tdsState.queryBuilderState;
|
52
|
+
|
53
|
+
const instanceVal = new ColSpecArrayInstance(Multiplicity.ONE, undefined);
|
54
|
+
|
55
|
+
const colSepcArray = new ColSpecArray();
|
56
|
+
instanceVal.values = [colSepcArray];
|
57
|
+
|
58
|
+
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
59
|
+
const colSpec = new ColSpec();
|
60
|
+
colSepcArray.colSpecs.push(colSpec);
|
61
|
+
colSpec.name = projectionColumnState.columnName;
|
62
|
+
// column projection
|
63
|
+
let columnLambda: ValueSpecification;
|
64
|
+
if (
|
65
|
+
projectionColumnState instanceof QueryBuilderSimpleProjectionColumnState
|
66
|
+
) {
|
67
|
+
columnLambda = buildGenericLambdaFunctionInstanceValue(
|
68
|
+
projectionColumnState.lambdaParameterName,
|
69
|
+
[
|
70
|
+
buildPropertyExpressionChain(
|
71
|
+
projectionColumnState.propertyExpressionState.propertyExpression,
|
72
|
+
projectionColumnState.propertyExpressionState.queryBuilderState,
|
73
|
+
projectionColumnState.lambdaParameterName,
|
74
|
+
options,
|
75
|
+
),
|
76
|
+
],
|
77
|
+
queryBuilderState.graphManagerState.graph,
|
78
|
+
);
|
79
|
+
} else if (
|
80
|
+
projectionColumnState instanceof
|
81
|
+
QueryBuilderDerivationProjectionColumnState
|
82
|
+
) {
|
83
|
+
columnLambda = new INTERNAL__UnknownValueSpecification(
|
84
|
+
V1_serializeRawValueSpecification(
|
85
|
+
V1_transformRawLambda(
|
86
|
+
projectionColumnState.lambda,
|
87
|
+
new V1_GraphTransformerContextBuilder(
|
88
|
+
// TODO?: do we need to include the plugins here?
|
89
|
+
[],
|
90
|
+
)
|
91
|
+
.withKeepSourceInformationFlag(
|
92
|
+
Boolean(options?.keepSourceInformation),
|
93
|
+
)
|
94
|
+
.build(),
|
95
|
+
),
|
96
|
+
),
|
97
|
+
);
|
98
|
+
} else {
|
99
|
+
throw new UnsupportedOperationError(
|
100
|
+
`Can't build relation project() column expression: unsupported projection column state`,
|
101
|
+
projectionColumnState,
|
102
|
+
);
|
103
|
+
}
|
104
|
+
colSpec.function1 = columnLambda;
|
105
|
+
});
|
106
|
+
projectFunction.parametersValues = [precedingExpression, instanceVal];
|
107
|
+
return projectFunction;
|
108
|
+
};
|
@@ -0,0 +1,64 @@
|
|
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 { QueryBuilderState } from '../QueryBuilderState.js';
|
18
|
+
|
19
|
+
export interface FetchStructureLayoutConfig {
|
20
|
+
label: string;
|
21
|
+
showInFetchPanel: boolean;
|
22
|
+
}
|
23
|
+
|
24
|
+
export abstract class QueryBuilderWorkflowState {
|
25
|
+
abstract get showStatusBar(): boolean;
|
26
|
+
|
27
|
+
abstract getFetchStructureLayoutConfig(
|
28
|
+
state: QueryBuilderState,
|
29
|
+
): FetchStructureLayoutConfig;
|
30
|
+
}
|
31
|
+
|
32
|
+
export class QueryBuilderAdvancedWorkflowState extends QueryBuilderWorkflowState {
|
33
|
+
get showStatusBar(): boolean {
|
34
|
+
return true;
|
35
|
+
}
|
36
|
+
|
37
|
+
override getFetchStructureLayoutConfig(
|
38
|
+
state: QueryBuilderState,
|
39
|
+
): FetchStructureLayoutConfig {
|
40
|
+
return {
|
41
|
+
label: 'fetch structure',
|
42
|
+
showInFetchPanel: true,
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
static INSTANCE = new QueryBuilderAdvancedWorkflowState();
|
47
|
+
}
|
48
|
+
|
49
|
+
export class QueryBuilderDataBrowserWorkflow extends QueryBuilderWorkflowState {
|
50
|
+
override get showStatusBar(): boolean {
|
51
|
+
return false;
|
52
|
+
}
|
53
|
+
|
54
|
+
override getFetchStructureLayoutConfig(
|
55
|
+
state: QueryBuilderState,
|
56
|
+
): FetchStructureLayoutConfig {
|
57
|
+
return {
|
58
|
+
label: state.fetchStructureState.implementation.fetchLabel,
|
59
|
+
showInFetchPanel: false,
|
60
|
+
};
|
61
|
+
}
|
62
|
+
|
63
|
+
static readonly INSTANCE = new QueryBuilderDataBrowserWorkflow();
|
64
|
+
}
|
@@ -21,7 +21,7 @@ import type {
|
|
21
21
|
} from '@finos/legend-graph';
|
22
22
|
import { ClassQueryBuilderState } from './ClassQueryBuilderState.js';
|
23
23
|
import type { QueryBuilderConfig } from '../../graph-manager/QueryBuilderConfig.js';
|
24
|
-
import type { QueryBuilderWorkflowState } from '../workflow/QueryBuilderWorkFlowState.js';
|
24
|
+
import type { QueryBuilderWorkflowState } from '../query-workflow/QueryBuilderWorkFlowState.js';
|
25
25
|
|
26
26
|
// Note: We may want to move it to extend QueryBuilderState directly
|
27
27
|
// but for now we will use the same setup as class as class, mapping, runtime are editable
|
@@ -28,7 +28,7 @@ import { getNullableFirstEntry } from '@finos/legend-shared';
|
|
28
28
|
import { renderMappingQueryBuilderSetupPanelContent } from '../../components/workflows/MappingQueryBuilder.js';
|
29
29
|
import { QueryBuilderState } from '../QueryBuilderState.js';
|
30
30
|
import type { QueryBuilderConfig } from '../../graph-manager/QueryBuilderConfig.js';
|
31
|
-
import type { QueryBuilderWorkflowState } from '../workflow/QueryBuilderWorkFlowState.js';
|
31
|
+
import type { QueryBuilderWorkflowState } from '../query-workflow/QueryBuilderWorkFlowState.js';
|
32
32
|
|
33
33
|
export class MappingQueryBuilderState extends QueryBuilderState {
|
34
34
|
readonly onMappingChange?: ((val: Mapping) => void) | undefined;
|
@@ -34,7 +34,7 @@ import { action, makeObservable, observable } from 'mobx';
|
|
34
34
|
import { renderServiceQueryBuilderSetupPanelContent } from '../../components/workflows/ServiceQueryBuilder.js';
|
35
35
|
import { QueryBuilderState } from '../QueryBuilderState.js';
|
36
36
|
import type { QueryBuilderConfig } from '../../graph-manager/QueryBuilderConfig.js';
|
37
|
-
import type { QueryBuilderWorkflowState } from '../workflow/QueryBuilderWorkFlowState.js';
|
37
|
+
import type { QueryBuilderWorkflowState } from '../query-workflow/QueryBuilderWorkFlowState.js';
|
38
38
|
|
39
39
|
export type ServiceExecutionContext = {
|
40
40
|
key: string;
|
package/tsconfig.json
CHANGED
@@ -92,6 +92,7 @@
|
|
92
92
|
"./src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.ts",
|
93
93
|
"./src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.ts",
|
94
94
|
"./src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.ts",
|
95
|
+
"./src/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.ts",
|
95
96
|
"./src/stores/fetch-structure/tds/QueryBuilderTDSColumnState.ts",
|
96
97
|
"./src/stores/fetch-structure/tds/QueryBuilderTDSHelper.ts",
|
97
98
|
"./src/stores/fetch-structure/tds/QueryBuilderTDSState.ts",
|
@@ -134,6 +135,7 @@
|
|
134
135
|
"./src/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.ts",
|
135
136
|
"./src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts",
|
136
137
|
"./src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts",
|
138
|
+
"./src/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.ts",
|
137
139
|
"./src/stores/fetch-structure/tds/window/QueryBuilderWindowGroupByOperatorLoader.ts",
|
138
140
|
"./src/stores/fetch-structure/tds/window/QueryBuilderWindowState.ts",
|
139
141
|
"./src/stores/fetch-structure/tds/window/QueryBuilderWindowStateBuilder.ts",
|
@@ -170,6 +172,7 @@
|
|
170
172
|
"./src/stores/milestoning/QueryBuilderMilestoningImplementation.ts",
|
171
173
|
"./src/stores/milestoning/QueryBuilderMilestoningState.ts",
|
172
174
|
"./src/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.ts",
|
175
|
+
"./src/stores/query-workflow/QueryBuilderWorkFlowState.ts",
|
173
176
|
"./src/stores/shared/LambdaEditorState.ts",
|
174
177
|
"./src/stores/shared/LambdaParameterState.ts",
|
175
178
|
"./src/stores/shared/ValueSpecificationEditorHelper.ts",
|
@@ -177,7 +180,6 @@
|
|
177
180
|
"./src/stores/watermark/QueryBuilderWatermarkState.ts",
|
178
181
|
"./src/stores/watermark/QueryBuilderWatermarkStateBuilder.ts",
|
179
182
|
"./src/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.ts",
|
180
|
-
"./src/stores/workflow/QueryBuilderWorkFlowState.ts",
|
181
183
|
"./src/stores/workflows/ClassQueryBuilderState.ts",
|
182
184
|
"./src/stores/workflows/FunctionQueryBuilderState.ts",
|
183
185
|
"./src/stores/workflows/MappingQueryBuilderState.ts",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderWorkFlowState.d.ts","sourceRoot":"","sources":["../../../src/stores/workflow/QueryBuilderWorkFlowState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8BAAsB,yBAAyB;IAC7C,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC;CACvC;AAED,qBAAa,iCAAkC,SAAQ,yBAAyB;IAC9E,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,MAAM,CAAC,QAAQ,oCAA2C;CAC3D"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderWorkFlowState.js","sourceRoot":"","sources":["../../../src/stores/workflow/QueryBuilderWorkFlowState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,OAAgB,yBAAyB;CAE9C;AAED,MAAM,OAAO,iCAAkC,SAAQ,yBAAyB;IAC9E,IAAI,aAAa;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,QAAQ,GAAG,IAAI,iCAAiC,EAAE,CAAC"}
|