@finos/legend-query-builder 4.14.30 → 4.14.32
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/QueryBuilderPropertyExpressionEditor.d.ts +3 -3
- package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
- package/lib/components/QueryBuilderPropertyExpressionEditor.js +23 -15
- package/lib/components/QueryBuilderPropertyExpressionEditor.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/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +7 -7
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.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 +40 -5
- 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 +3 -3
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +9 -2
- 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/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.d.ts +20 -0
- 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/{src/stores/workflow/QueryBuilderWorkFlowState.ts → lib/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.d.ts} +5 -12
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.d.ts.map +1 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.js +54 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.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 +4 -4
- package/src/components/QueryBuilder.tsx +77 -2
- package/src/components/QueryBuilderPropertyExpressionEditor.tsx +34 -20
- package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +1 -1
- package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +29 -29
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +9 -16
- 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 +83 -10
- 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 +9 -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/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.ts +103 -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 +4 -1
- package/lib/stores/workflow/QueryBuilderWorkFlowState.d.ts.map +0 -1
- package/lib/stores/workflow/QueryBuilderWorkFlowState.js.map +0 -1
@@ -26,7 +26,7 @@ import {
|
|
26
26
|
} from '@finos/legend-shared';
|
27
27
|
import type { QueryBuilderState } from './QueryBuilderState.js';
|
28
28
|
import {
|
29
|
-
|
29
|
+
AbstractPropertyExpression,
|
30
30
|
type EnumValueInstanceValue,
|
31
31
|
type FunctionExpression,
|
32
32
|
type GraphFetchTreeInstanceValue,
|
@@ -36,7 +36,8 @@ import {
|
|
36
36
|
type INTERNAL__PropagatedValue,
|
37
37
|
type ValueSpecification,
|
38
38
|
type CollectionInstanceValue,
|
39
|
-
|
39
|
+
LambdaFunctionInstanceValue,
|
40
|
+
type ColSpecArrayInstance,
|
40
41
|
InstanceValue,
|
41
42
|
INTERNAL__UnknownValueSpecification,
|
42
43
|
matchFunctionName,
|
@@ -92,6 +93,10 @@ import {
|
|
92
93
|
import { checkIfEquivalent } from './milestoning/QueryBuilderMilestoningHelper.js';
|
93
94
|
import type { QueryBuilderParameterValue } from './QueryBuilderParametersState.js';
|
94
95
|
import { QueryBuilderEmbeddedFromExecutionContextState } from './QueryBuilderExecutionContextState.js';
|
96
|
+
import {
|
97
|
+
isTypedProjectionExpression,
|
98
|
+
processTypedTDSProjectExpression,
|
99
|
+
} from './fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.js';
|
95
100
|
|
96
101
|
const processGetAllExpression = (
|
97
102
|
expression: SimpleFunctionExpression,
|
@@ -481,6 +486,7 @@ export class QueryBuilderValueSpecificationProcessor
|
|
481
486
|
) {
|
482
487
|
processTDSProjectionDerivationExpression(
|
483
488
|
valueSpecification,
|
489
|
+
undefined,
|
484
490
|
this.parentExpression,
|
485
491
|
this.queryBuilderState,
|
486
492
|
);
|
@@ -637,16 +643,25 @@ export class QueryBuilderValueSpecificationProcessor
|
|
637
643
|
);
|
638
644
|
return;
|
639
645
|
} else if (
|
640
|
-
matchFunctionName(
|
641
|
-
functionName,
|
646
|
+
matchFunctionName(functionName, [
|
642
647
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
643
|
-
|
648
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_PROJECT,
|
649
|
+
])
|
644
650
|
) {
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
651
|
+
if (isTypedProjectionExpression(valueSpecification)) {
|
652
|
+
processTypedTDSProjectExpression(
|
653
|
+
valueSpecification,
|
654
|
+
this.queryBuilderState,
|
655
|
+
this.parentLambda,
|
656
|
+
);
|
657
|
+
} else {
|
658
|
+
processTDSProjectExpression(
|
659
|
+
valueSpecification,
|
660
|
+
this.queryBuilderState,
|
661
|
+
this.parentLambda,
|
662
|
+
);
|
663
|
+
}
|
664
|
+
|
650
665
|
return;
|
651
666
|
} else if (
|
652
667
|
matchFunctionName(
|
@@ -835,6 +850,7 @@ export class QueryBuilderValueSpecificationProcessor
|
|
835
850
|
if (
|
836
851
|
matchFunctionName(this.parentExpression.functionName, [
|
837
852
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
853
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_PROJECT,
|
838
854
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_GROUP_BY,
|
839
855
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_AGG,
|
840
856
|
...Object.values(
|
@@ -844,6 +860,7 @@ export class QueryBuilderValueSpecificationProcessor
|
|
844
860
|
) {
|
845
861
|
processTDSProjectionColumnPropertyExpression(
|
846
862
|
valueSpecification,
|
863
|
+
undefined,
|
847
864
|
this.queryBuilderState,
|
848
865
|
);
|
849
866
|
return;
|
@@ -903,6 +920,62 @@ export class QueryBuilderValueSpecificationProcessor
|
|
903
920
|
): void {
|
904
921
|
throw new UnsupportedOperationError();
|
905
922
|
}
|
923
|
+
|
924
|
+
visit_ColSpecArrayInstance(valueSpecification: ColSpecArrayInstance): void {
|
925
|
+
assertNonNullable(
|
926
|
+
this.parentExpression,
|
927
|
+
`Can't process col spec aray instance: parent expression cannot be retrieved`,
|
928
|
+
);
|
929
|
+
|
930
|
+
if (
|
931
|
+
matchFunctionName(this.parentExpression.functionName, [
|
932
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_PROJECT,
|
933
|
+
])
|
934
|
+
) {
|
935
|
+
const spec = valueSpecification.values;
|
936
|
+
assertTrue(
|
937
|
+
spec.length === 1,
|
938
|
+
`Can't process col spec array instance: value expected to be of size 1`,
|
939
|
+
);
|
940
|
+
guaranteeNonNullable(spec[0]).colSpecs.forEach((col) => {
|
941
|
+
const _function1 = guaranteeType(
|
942
|
+
col.function1,
|
943
|
+
LambdaFunctionInstanceValue,
|
944
|
+
`Can't process col spec: function1 not a lambda function instance value`,
|
945
|
+
);
|
946
|
+
assertTrue(_function1.values.length === 1);
|
947
|
+
const lambdaVal = guaranteeNonNullable(_function1.values[0]);
|
948
|
+
assertTrue(lambdaVal.expressionSequence.length === 1);
|
949
|
+
const expression = guaranteeNonNullable(
|
950
|
+
lambdaVal.expressionSequence[0],
|
951
|
+
);
|
952
|
+
|
953
|
+
if (expression instanceof AbstractPropertyExpression) {
|
954
|
+
processTDSProjectionColumnPropertyExpression(
|
955
|
+
expression,
|
956
|
+
col.name,
|
957
|
+
this.queryBuilderState,
|
958
|
+
);
|
959
|
+
} else if (expression instanceof INTERNAL__UnknownValueSpecification) {
|
960
|
+
assertNonNullable(
|
961
|
+
this.parentExpression,
|
962
|
+
`Can't process unknown value: parent expression cannot be retrieved`,
|
963
|
+
);
|
964
|
+
processTDSProjectionDerivationExpression(
|
965
|
+
expression,
|
966
|
+
col.name,
|
967
|
+
this.parentExpression,
|
968
|
+
this.queryBuilderState,
|
969
|
+
);
|
970
|
+
}
|
971
|
+
});
|
972
|
+
|
973
|
+
return;
|
974
|
+
}
|
975
|
+
throw new UnsupportedOperationError(
|
976
|
+
`Can't process col spec array expression with parent expression of function ${this.parentExpression.functionName}()`,
|
977
|
+
);
|
978
|
+
}
|
906
979
|
}
|
907
980
|
|
908
981
|
export const processParameters = (
|
@@ -205,4 +205,9 @@ export type LambdaFunctionBuilderOption = {
|
|
205
205
|
* limit for the query results if it exists so the exported results contain all the data
|
206
206
|
*/
|
207
207
|
isExportingResult?: boolean | undefined;
|
208
|
+
/**
|
209
|
+
* Set this flag to `true` when you want to write to typed TDS function using the `Relation`
|
210
|
+
* typed in engine. This is still an experimental feature, hence we should only enable this flag when user wants to enable this directly.
|
211
|
+
*/
|
212
|
+
useTypedRelationFunctions?: boolean | undefined;
|
208
213
|
};
|
@@ -41,7 +41,7 @@ import {
|
|
41
41
|
INTERNAL__BasicQueryBuilderState,
|
42
42
|
type QueryBuilderState,
|
43
43
|
} from '../QueryBuilderState.js';
|
44
|
-
import { QueryBuilderAdvancedWorkflowState } from '../workflow/QueryBuilderWorkFlowState.js';
|
44
|
+
import { QueryBuilderAdvancedWorkflowState } from '../query-workflow/QueryBuilderWorkFlowState.js';
|
45
45
|
|
46
46
|
export class TEST__LegendApplicationPluginManager
|
47
47
|
extends LegendApplicationPluginManager<LegendApplicationPlugin>
|
@@ -58,6 +58,7 @@ export abstract class QueryBuilderFetchStructureImplementationState
|
|
58
58
|
abstract get usedExplorerTreePropertyNodeIDs(): string[];
|
59
59
|
abstract get fetchStructureValidationIssues(): string[];
|
60
60
|
abstract get allValidationIssues(): string[];
|
61
|
+
abstract get fetchLabel(): string;
|
61
62
|
|
62
63
|
abstract onClassChange(_class: Class | undefined): void;
|
63
64
|
abstract revealCompilationError(compilationError: CompilationError): boolean;
|
@@ -29,6 +29,21 @@ import {
|
|
29
29
|
type QueryBuilderFetchStructureImplementationState,
|
30
30
|
} from './QueryBuilderFetchStructureImplementationState.js';
|
31
31
|
|
32
|
+
export const onChangeFetchStructureImplementation =
|
33
|
+
(
|
34
|
+
implementationType: FETCH_STRUCTURE_IMPLEMENTATION,
|
35
|
+
fetchStructureState: QueryBuilderFetchStructureState,
|
36
|
+
): (() => void) =>
|
37
|
+
(): void => {
|
38
|
+
if (fetchStructureState.implementation.type !== implementationType) {
|
39
|
+
fetchStructureState.implementation.checkBeforeChangingImplementation(
|
40
|
+
() => {
|
41
|
+
fetchStructureState.changeImplementation(implementationType);
|
42
|
+
},
|
43
|
+
);
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
32
47
|
export class QueryBuilderFetchStructureState {
|
33
48
|
readonly queryBuilderState: QueryBuilderState;
|
34
49
|
implementation: QueryBuilderFetchStructureImplementationState;
|
@@ -292,6 +292,7 @@ export class QueryBuilderGraphFetchTreeState
|
|
292
292
|
setSerializationState: action,
|
293
293
|
setChecked: action,
|
294
294
|
initialize: action,
|
295
|
+
checkBeforeChangingImplementation: action,
|
295
296
|
});
|
296
297
|
|
297
298
|
// try to initialize the graph-fetch tree data using the setup class
|
@@ -304,6 +305,10 @@ export class QueryBuilderGraphFetchTreeState
|
|
304
305
|
return FETCH_STRUCTURE_IMPLEMENTATION.GRAPH_FETCH;
|
305
306
|
}
|
306
307
|
|
308
|
+
override get fetchLabel(): string {
|
309
|
+
return 'Class Properties';
|
310
|
+
}
|
311
|
+
|
307
312
|
get usedExplorerTreePropertyNodeIDs(): string[] {
|
308
313
|
if (!this.treeData) {
|
309
314
|
return [];
|
File without changes
|
@@ -154,6 +154,7 @@ export class QueryBuilderTDSState
|
|
154
154
|
initializeWithQuery: action,
|
155
155
|
setShowPostFilterPanel: action,
|
156
156
|
setShowWindowFuncPanel: action,
|
157
|
+
checkBeforeChangingImplementation: action,
|
157
158
|
convertDerivationProjectionObjects: flow,
|
158
159
|
fetchDerivedReturnTypes: flow,
|
159
160
|
});
|
@@ -194,6 +195,10 @@ export class QueryBuilderTDSState
|
|
194
195
|
);
|
195
196
|
}
|
196
197
|
|
198
|
+
override get fetchLabel(): string {
|
199
|
+
return 'Columns';
|
200
|
+
}
|
201
|
+
|
197
202
|
override get TEMPORARY__showPostFetchStructurePanel(): boolean {
|
198
203
|
return (
|
199
204
|
this.queryBuilderState.filterState.showPanel ||
|
@@ -44,7 +44,7 @@ import {
|
|
44
44
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
45
45
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
46
46
|
} from '../../../../graph/QueryBuilderMetaModelConst.js';
|
47
|
-
import type
|
47
|
+
import { type QueryBuilderState } from '../../../QueryBuilderState.js';
|
48
48
|
import { QueryBuilderValueSpecificationProcessor } from '../../../QueryBuilderStateBuilder.js';
|
49
49
|
import {
|
50
50
|
extractNullableNumberFromInstanceValue,
|
@@ -142,6 +142,7 @@ export const processTDSProjectExpression = (
|
|
142
142
|
|
143
143
|
export const processTDSProjectionColumnPropertyExpression = (
|
144
144
|
expression: AbstractPropertyExpression,
|
145
|
+
columnName: string | undefined,
|
145
146
|
queryBuilderState: QueryBuilderState,
|
146
147
|
): void => {
|
147
148
|
if (
|
@@ -200,7 +201,9 @@ export const processTDSProjectionColumnPropertyExpression = (
|
|
200
201
|
);
|
201
202
|
|
202
203
|
tdsState.addColumn(columnState, { skipSorting: true });
|
203
|
-
|
204
|
+
if (columnName) {
|
205
|
+
columnState.setColumnName(columnName);
|
206
|
+
}
|
204
207
|
// NOTE: technically we should set the lambda parameter name when we process
|
205
208
|
// the lambda, not when we process the lambda body like this, but that requires
|
206
209
|
// some setup, so it's easier to do it here. The validation of this should have
|
@@ -211,6 +214,7 @@ export const processTDSProjectionColumnPropertyExpression = (
|
|
211
214
|
|
212
215
|
export const processTDSProjectionDerivationExpression = (
|
213
216
|
value: INTERNAL__UnknownValueSpecification,
|
217
|
+
columnName: string | undefined,
|
214
218
|
parentExpression: SimpleFunctionExpression,
|
215
219
|
queryBuilderState: QueryBuilderState,
|
216
220
|
): void => {
|
@@ -236,6 +240,9 @@ export const processTDSProjectionDerivationExpression = (
|
|
236
240
|
new RawLambda(rawLambdaProtocol.parameters, rawLambdaProtocol.body),
|
237
241
|
);
|
238
242
|
projectionState.addColumn(columnState, { skipSorting: true });
|
243
|
+
if (columnName) {
|
244
|
+
columnState.setColumnName(columnName);
|
245
|
+
}
|
239
246
|
}
|
240
247
|
};
|
241
248
|
|
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
|
+
};
|