@finos/legend-application-query 5.0.2 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/QueryBuilderFetchStructurePanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderFetchStructurePanel.js +1 -1
- package/lib/components/QueryBuilderFetchStructurePanel.js.map +1 -1
- package/lib/components/QueryBuilderFilterPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderFilterPanel.js +17 -4
- package/lib/components/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/components/QueryBuilderFunctionsExplorerPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderFunctionsExplorerPanel.js.map +1 -1
- package/lib/components/QueryBuilderParameterPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderParameterPanel.js +3 -2
- package/lib/components/QueryBuilderParameterPanel.js.map +1 -1
- package/lib/components/QueryBuilderPostFilterPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderPostFilterPanel.js +17 -4
- package/lib/components/QueryBuilderPostFilterPanel.js.map +1 -1
- package/lib/components/QueryBuilderProjectionPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderProjectionPanel.js +6 -2
- package/lib/components/QueryBuilderProjectionPanel.js.map +1 -1
- package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderResultPanel.js +3 -1
- package/lib/components/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/QueryBuilderSetupPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderSetupPanel.js +5 -3
- package/lib/components/QueryBuilderSetupPanel.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderFetchStructureState.d.ts +2 -1
- package/lib/stores/QueryBuilderFetchStructureState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderFetchStructureState.js +2 -2
- package/lib/stores/QueryBuilderFetchStructureState.js.map +1 -1
- package/lib/stores/QueryBuilderFilterState.d.ts +4 -0
- package/lib/stores/QueryBuilderFilterState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderFilterState.js +28 -2
- package/lib/stores/QueryBuilderFilterState.js.map +1 -1
- package/lib/stores/QueryBuilderOperatorLoader.d.ts +47 -0
- package/lib/stores/QueryBuilderOperatorLoader.d.ts.map +1 -0
- package/lib/stores/QueryBuilderOperatorLoader.js +94 -0
- package/lib/stores/QueryBuilderOperatorLoader.js.map +1 -0
- package/lib/stores/QueryBuilderPostFilterState.d.ts +5 -2
- package/lib/stores/QueryBuilderPostFilterState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderPostFilterState.js +25 -1
- package/lib/stores/QueryBuilderPostFilterState.js.map +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.d.ts +4 -3
- package/lib/stores/QueryBuilderPreviewDataHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.js +77 -97
- package/lib/stores/QueryBuilderPreviewDataHelper.js.map +1 -1
- package/lib/stores/QueryBuilderProjectionState.d.ts +3 -2
- package/lib/stores/QueryBuilderProjectionState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderProjectionState.js +17 -32
- package/lib/stores/QueryBuilderProjectionState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts +1 -0
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +8 -58
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderTestUtils.d.ts +24 -0
- package/lib/stores/QueryBuilderTestUtils.d.ts.map +1 -0
- package/lib/stores/QueryBuilderTestUtils.js +49 -0
- package/lib/stores/QueryBuilderTestUtils.js.map +1 -0
- package/lib/stores/QueryBuilderTypeaheadHelper.d.ts +24 -0
- package/lib/stores/QueryBuilderTypeaheadHelper.d.ts.map +1 -0
- package/lib/stores/QueryBuilderTypeaheadHelper.js +89 -0
- package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -0
- package/package.json +8 -8
- package/src/components/QueryBuilderFetchStructurePanel.tsx +4 -1
- package/src/components/QueryBuilderFilterPanel.tsx +31 -4
- package/src/components/QueryBuilderFunctionsExplorerPanel.tsx +1 -0
- package/src/components/QueryBuilderParameterPanel.tsx +3 -2
- package/src/components/QueryBuilderPostFilterPanel.tsx +31 -4
- package/src/components/QueryBuilderProjectionPanel.tsx +19 -2
- package/src/components/QueryBuilderResultPanel.tsx +6 -0
- package/src/components/QueryBuilderSetupPanel.tsx +5 -3
- package/src/stores/QueryBuilderFetchStructureState.ts +9 -2
- package/src/stores/QueryBuilderFilterState.ts +43 -0
- package/src/stores/QueryBuilderOperatorLoader.ts +133 -0
- package/src/stores/QueryBuilderPostFilterState.ts +40 -1
- package/src/stores/QueryBuilderPreviewDataHelper.ts +122 -217
- package/src/stores/QueryBuilderProjectionState.ts +29 -46
- package/src/stores/QueryBuilderState.ts +23 -94
- package/src/stores/QueryBuilderTestUtils.ts +93 -0
- package/src/stores/QueryBuilderTypeaheadHelper.ts +149 -0
- package/tsconfig.json +3 -0
@@ -14,27 +14,12 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import {
|
18
|
-
|
19
|
-
|
20
|
-
type PureModel,
|
21
|
-
GenericType,
|
22
|
-
GenericTypeExplicitReference,
|
23
|
-
PrimitiveInstanceValue,
|
24
|
-
PRIMITIVE_TYPE,
|
25
|
-
CollectionInstanceValue,
|
26
|
-
CORE_PURE_PATH,
|
27
|
-
extractElementNameFromPath,
|
28
|
-
FunctionType,
|
29
|
-
LambdaFunction,
|
30
|
-
Multiplicity,
|
31
|
-
SimpleFunctionExpression,
|
32
|
-
TYPICAL_MULTIPLICITY_TYPE,
|
17
|
+
import type {
|
18
|
+
RawLambda,
|
19
|
+
AbstractPropertyExpression,
|
33
20
|
} from '@finos/legend-graph';
|
34
|
-
import {
|
35
|
-
|
36
|
-
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
37
|
-
} from '../QueryBuilder_Const.js';
|
21
|
+
import { guaranteeNonNullable } from '@finos/legend-shared';
|
22
|
+
import type { QueryBuilderAggregateOperator } from './QueryBuilderAggregationState.js';
|
38
23
|
import { QueryBuilderAggregateOperator_Average } from './aggregateOperators/QueryBuilderAggregateOperator_Average.js';
|
39
24
|
import { QueryBuilderAggregateOperator_Count } from './aggregateOperators/QueryBuilderAggregateOperator_Count.js';
|
40
25
|
import { QueryBuilderAggregateOperator_DistinctCount } from './aggregateOperators/QueryBuilderAggregateOperator_DistinctCount.js';
|
@@ -43,109 +28,82 @@ import { QueryBuilderAggregateOperator_Min } from './aggregateOperators/QueryBui
|
|
43
28
|
import { QueryBuilderAggregateOperator_StdDev_Population } from './aggregateOperators/QueryBuilderAggregateOperator_StdDev_Population.js';
|
44
29
|
import { QueryBuilderAggregateOperator_StdDev_Sample } from './aggregateOperators/QueryBuilderAggregateOperator_StdDev_Sample.js';
|
45
30
|
import { QueryBuilderAggregateOperator_Sum } from './aggregateOperators/QueryBuilderAggregateOperator_Sum.js';
|
46
|
-
import
|
47
|
-
import {
|
48
|
-
import {
|
31
|
+
import { QueryBuilderSimpleProjectionColumnState } from './QueryBuilderProjectionState.js';
|
32
|
+
import type { QueryBuilderState } from './QueryBuilderState.js';
|
33
|
+
import {
|
34
|
+
COLUMN_SORT_TYPE,
|
35
|
+
SortColumnState,
|
36
|
+
} from './QueryResultSetModifierState.js';
|
49
37
|
|
50
|
-
const
|
51
|
-
|
52
|
-
|
53
|
-
aggregates: [QueryBuilderAggregateOperator, string][],
|
54
|
-
includePropertyValue: boolean,
|
55
|
-
graph: PureModel,
|
56
|
-
): SimpleFunctionExpression => {
|
57
|
-
const multiplicityOne = graph.getTypicalMultiplicity(
|
58
|
-
TYPICAL_MULTIPLICITY_TYPE.ONE,
|
59
|
-
);
|
60
|
-
const typeAny = graph.getType(CORE_PURE_PATH.ANY);
|
61
|
-
const typeString = graph.getPrimitiveType(PRIMITIVE_TYPE.STRING);
|
62
|
-
const lambdaFunction = new LambdaFunction(
|
63
|
-
new FunctionType(typeAny, multiplicityOne),
|
64
|
-
);
|
38
|
+
const PREVIEW_DATA_TAKE_LIMIT = 10;
|
39
|
+
const PREVIEW_DATA_NON_NUMERIC_VALUE_COLUMN_NAME = 'Value';
|
40
|
+
const PREVIEW_DATA_NON_NUMERIC_COUNT_COLUMN_NAME = 'Count';
|
65
41
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
42
|
+
enum NUMERIC_AGG_FUNC {
|
43
|
+
COUNT = 'Count',
|
44
|
+
DISTINCT_COUNT = 'Distinct Count',
|
45
|
+
SUM = 'Sum',
|
46
|
+
MIN = 'Min',
|
47
|
+
MAX = 'Max',
|
48
|
+
AVERAGE = 'Average',
|
49
|
+
STD_DEV_POPULATION = 'Std Dev (Population)',
|
50
|
+
STD_DEV_SAMPLE = 'Std Dev (Sample)',
|
51
|
+
}
|
70
52
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
53
|
+
const NUMERIC_AGG_FUNC_TO_AGG_OP: [
|
54
|
+
NUMERIC_AGG_FUNC,
|
55
|
+
typeof QueryBuilderAggregateOperator,
|
56
|
+
][] = [
|
57
|
+
[NUMERIC_AGG_FUNC.COUNT, QueryBuilderAggregateOperator_Count],
|
58
|
+
[
|
59
|
+
NUMERIC_AGG_FUNC.DISTINCT_COUNT,
|
60
|
+
QueryBuilderAggregateOperator_DistinctCount,
|
61
|
+
],
|
62
|
+
[NUMERIC_AGG_FUNC.SUM, QueryBuilderAggregateOperator_Sum],
|
63
|
+
[NUMERIC_AGG_FUNC.MIN, QueryBuilderAggregateOperator_Min],
|
64
|
+
[NUMERIC_AGG_FUNC.MAX, QueryBuilderAggregateOperator_Max],
|
65
|
+
[NUMERIC_AGG_FUNC.AVERAGE, QueryBuilderAggregateOperator_Average],
|
66
|
+
[
|
67
|
+
NUMERIC_AGG_FUNC.STD_DEV_POPULATION,
|
68
|
+
QueryBuilderAggregateOperator_StdDev_Population,
|
69
|
+
],
|
70
|
+
[
|
71
|
+
NUMERIC_AGG_FUNC.STD_DEV_SAMPLE,
|
72
|
+
QueryBuilderAggregateOperator_StdDev_Sample,
|
73
|
+
],
|
74
|
+
];
|
85
75
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
colAliases.values.push(valueColAlias);
|
100
|
-
}
|
76
|
+
const createProjectionColumn = (
|
77
|
+
queryBuilderState: QueryBuilderState,
|
78
|
+
propertyExpression: AbstractPropertyExpression,
|
79
|
+
columnName: string,
|
80
|
+
): QueryBuilderSimpleProjectionColumnState => {
|
81
|
+
const col = new QueryBuilderSimpleProjectionColumnState(
|
82
|
+
queryBuilderState.fetchStructureState.projectionState,
|
83
|
+
propertyExpression,
|
84
|
+
false,
|
85
|
+
);
|
86
|
+
col.setColumnName(columnName);
|
87
|
+
return col;
|
88
|
+
};
|
101
89
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
DEFAULT_LAMBDA_VARIABLE_NAME,
|
110
|
-
[propertyExpression],
|
111
|
-
graph,
|
112
|
-
),
|
113
|
-
buildGenericLambdaFunctionInstanceValue(
|
114
|
-
DEFAULT_LAMBDA_VARIABLE_NAME,
|
115
|
-
[
|
116
|
-
pair[0].buildAggregateExpression(
|
117
|
-
propertyExpression,
|
118
|
-
DEFAULT_LAMBDA_VARIABLE_NAME,
|
119
|
-
graph,
|
120
|
-
),
|
121
|
-
],
|
122
|
-
graph,
|
123
|
-
),
|
124
|
-
];
|
125
|
-
aggregateLambdas.values.push(aggregateFunctionExpression);
|
90
|
+
const createQueryBuilderState = (
|
91
|
+
queryBuilderState: QueryBuilderState,
|
92
|
+
): QueryBuilderState => {
|
93
|
+
const builderState = queryBuilderState.createBareBuilderState();
|
94
|
+
builderState.querySetupState = queryBuilderState.querySetupState;
|
95
|
+
return builderState;
|
96
|
+
};
|
126
97
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
);
|
131
|
-
colAlias.values.push(pair[1]);
|
132
|
-
colAliases.values.push(colAlias);
|
133
|
-
});
|
134
|
-
groupByFunction.parametersValues = [
|
135
|
-
getAllFunction,
|
136
|
-
colLambdas,
|
137
|
-
aggregateLambdas,
|
138
|
-
colAliases,
|
139
|
-
];
|
140
|
-
lambdaFunction.expressionSequence[0] = groupByFunction;
|
141
|
-
return groupByFunction;
|
98
|
+
export type QueryBuilderPreviewData = {
|
99
|
+
columns: string[];
|
100
|
+
rows: { values: (string | number)[] }[];
|
142
101
|
};
|
143
102
|
|
144
103
|
export const buildNumericPreviewDataQuery = (
|
104
|
+
queryBuilderState: QueryBuilderState,
|
145
105
|
propertyExpression: AbstractPropertyExpression,
|
146
|
-
|
147
|
-
graph: PureModel,
|
148
|
-
): LambdaFunction => {
|
106
|
+
): RawLambda => {
|
149
107
|
// Build the following query
|
150
108
|
//
|
151
109
|
// ClassX.all()->groupBy(
|
@@ -171,44 +129,29 @@ export const buildNumericPreviewDataQuery = (
|
|
171
129
|
// 'Std Dev (Sample)'
|
172
130
|
// ]
|
173
131
|
// )
|
174
|
-
const
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
[
|
192
|
-
new QueryBuilderAggregateOperator_StdDev_Population(),
|
193
|
-
'Standard Deviation (Population)',
|
194
|
-
],
|
195
|
-
[
|
196
|
-
new QueryBuilderAggregateOperator_StdDev_Sample(),
|
197
|
-
'Standard Deviation (Sample)',
|
198
|
-
],
|
199
|
-
] as [QueryBuilderAggregateOperator, string][],
|
200
|
-
false,
|
201
|
-
graph,
|
202
|
-
);
|
203
|
-
lambdaFunction.expressionSequence[0] = groupByFunction;
|
204
|
-
return lambdaFunction;
|
132
|
+
const builderState = createQueryBuilderState(queryBuilderState);
|
133
|
+
const projectionState = builderState.fetchStructureState.projectionState;
|
134
|
+
const aggregationState = projectionState.aggregationState;
|
135
|
+
NUMERIC_AGG_FUNC_TO_AGG_OP.forEach((val) => {
|
136
|
+
const colState = createProjectionColumn(
|
137
|
+
builderState,
|
138
|
+
propertyExpression,
|
139
|
+
val[0],
|
140
|
+
);
|
141
|
+
projectionState.columns.push(colState);
|
142
|
+
const valAggOp = guaranteeNonNullable(
|
143
|
+
aggregationState.operators.find((t) => t instanceof val[1]),
|
144
|
+
);
|
145
|
+
aggregationState.changeColumnAggregateOperator(valAggOp, colState);
|
146
|
+
});
|
147
|
+
|
148
|
+
return builderState.resultState.buildExecutionRawLambda();
|
205
149
|
};
|
206
150
|
|
207
151
|
export const buildNonNumericPreviewDataQuery = (
|
152
|
+
queryBuilderState: QueryBuilderState,
|
208
153
|
propertyExpression: AbstractPropertyExpression,
|
209
|
-
|
210
|
-
graph: PureModel,
|
211
|
-
): LambdaFunction => {
|
154
|
+
): RawLambda => {
|
212
155
|
// Build the following query
|
213
156
|
//
|
214
157
|
// ClassX.all()->groupBy(
|
@@ -216,85 +159,47 @@ export const buildNonNumericPreviewDataQuery = (
|
|
216
159
|
// x|$x.prop
|
217
160
|
// ],
|
218
161
|
// [
|
219
|
-
// agg(x|$x.prop, x|$x->
|
162
|
+
// agg(x|$x.prop, x|$x->count())
|
220
163
|
// ],
|
221
164
|
// [
|
222
165
|
// 'Value',
|
223
166
|
// 'Count'
|
224
167
|
// ]
|
225
|
-
// )->
|
226
|
-
const
|
227
|
-
|
228
|
-
|
229
|
-
const typeAny = graph.getType(CORE_PURE_PATH.ANY);
|
230
|
-
const lambdaFunction = new LambdaFunction(
|
231
|
-
new FunctionType(typeAny, multiplicityOne),
|
232
|
-
);
|
233
|
-
|
234
|
-
// build groupBy()
|
235
|
-
const groupByFunction = buildGroupByFunction(
|
236
|
-
buildGetAllFunction(_class, multiplicityOne),
|
168
|
+
// )->sort([desc('Count'), asc('Value')])->take(10)
|
169
|
+
const builderState = createQueryBuilderState(queryBuilderState);
|
170
|
+
const valueProjectionColState = createProjectionColumn(
|
171
|
+
builderState,
|
237
172
|
propertyExpression,
|
238
|
-
|
239
|
-
QueryBuilderAggregateOperator,
|
240
|
-
string,
|
241
|
-
][],
|
242
|
-
true,
|
243
|
-
graph,
|
173
|
+
PREVIEW_DATA_NON_NUMERIC_VALUE_COLUMN_NAME,
|
244
174
|
);
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_SORT),
|
250
|
-
multiplicityOne,
|
251
|
-
);
|
252
|
-
const sortColumnFunctions = new CollectionInstanceValue(
|
253
|
-
new Multiplicity(2, 2),
|
254
|
-
undefined,
|
175
|
+
const valueCountProjectionState = createProjectionColumn(
|
176
|
+
builderState,
|
177
|
+
propertyExpression,
|
178
|
+
PREVIEW_DATA_NON_NUMERIC_COUNT_COLUMN_NAME,
|
255
179
|
);
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
]
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
);
|
264
|
-
const sortColumnName = new PrimitiveInstanceValue(
|
265
|
-
GenericTypeExplicitReference.create(
|
266
|
-
new GenericType(graph.getPrimitiveType(PRIMITIVE_TYPE.STRING)),
|
267
|
-
),
|
268
|
-
multiplicityOne,
|
269
|
-
);
|
270
|
-
sortColumnName.values = [pair[1]];
|
271
|
-
sortColumnFunction.parametersValues[0] = sortColumnName;
|
272
|
-
return sortColumnFunction;
|
273
|
-
});
|
274
|
-
sortFunction.parametersValues[0] = groupByFunction;
|
275
|
-
sortFunction.parametersValues[1] = sortColumnFunctions;
|
276
|
-
|
277
|
-
// build take()
|
278
|
-
const limit = new PrimitiveInstanceValue(
|
279
|
-
GenericTypeExplicitReference.create(
|
280
|
-
new GenericType(graph.getPrimitiveType(PRIMITIVE_TYPE.INTEGER)),
|
180
|
+
builderState.fetchStructureState.projectionState.columns = [
|
181
|
+
valueProjectionColState,
|
182
|
+
valueCountProjectionState,
|
183
|
+
];
|
184
|
+
const distinctCountOp = guaranteeNonNullable(
|
185
|
+
builderState.fetchStructureState.projectionState.aggregationState.operators.find(
|
186
|
+
(t) => t instanceof QueryBuilderAggregateOperator_Count,
|
281
187
|
),
|
282
|
-
multiplicityOne,
|
283
188
|
);
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
multiplicityOne,
|
189
|
+
builderState.fetchStructureState.projectionState.aggregationState.changeColumnAggregateOperator(
|
190
|
+
distinctCountOp,
|
191
|
+
valueCountProjectionState,
|
288
192
|
);
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
193
|
+
// result set
|
194
|
+
builderState.resultSetModifierState.limit = PREVIEW_DATA_TAKE_LIMIT;
|
195
|
+
const sortValueCount = new SortColumnState(
|
196
|
+
builderState,
|
197
|
+
valueCountProjectionState,
|
198
|
+
);
|
199
|
+
sortValueCount.sortType = COLUMN_SORT_TYPE.DESC;
|
200
|
+
builderState.resultSetModifierState.sortColumns = [
|
201
|
+
sortValueCount,
|
202
|
+
new SortColumnState(builderState, valueProjectionColState),
|
203
|
+
];
|
204
|
+
return builderState.resultState.buildExecutionRawLambda();
|
300
205
|
};
|
@@ -68,30 +68,22 @@ import {
|
|
68
68
|
RawLambda,
|
69
69
|
stub_RawLambda,
|
70
70
|
isStubbed_RawLambda,
|
71
|
-
buildRawLambdaFromLambdaFunction,
|
72
71
|
} from '@finos/legend-graph';
|
73
72
|
import {
|
74
73
|
DEFAULT_LAMBDA_VARIABLE_NAME,
|
75
74
|
QUERY_BUILDER_SOURCE_ID_LABEL,
|
76
75
|
} from '../QueryBuilder_Const.js';
|
77
|
-
import {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
import {
|
82
|
-
import {
|
83
|
-
import { QueryBuilderAggregateOperator_StdDev_Sample } from './aggregateOperators/QueryBuilderAggregateOperator_StdDev_Sample.js';
|
84
|
-
import { QueryBuilderAggregateOperator_DistinctCount } from './aggregateOperators/QueryBuilderAggregateOperator_DistinctCount.js';
|
85
|
-
import { QueryBuilderAggregateOperator_Min } from './aggregateOperators/QueryBuilderAggregateOperator_Min.js';
|
86
|
-
import { QueryBuilderAggregateOperator_Max } from './aggregateOperators/QueryBuilderAggregateOperator_Max.js';
|
87
|
-
import { QueryBuilderAggregateOperator_JoinString } from './aggregateOperators/QueryBuilderAggregateOperator_JoinString.js';
|
76
|
+
import {
|
77
|
+
type QueryBuilderAggregateOperator,
|
78
|
+
QueryBuilderAggregationState,
|
79
|
+
} from './QueryBuilderAggregationState.js';
|
80
|
+
import { buildGenericLambdaFunctionInstanceValue } from './QueryBuilderValueSpecificationBuilderHelper.js';
|
81
|
+
import { LambdaEditorState } from '@finos/legend-application';
|
88
82
|
import {
|
89
83
|
type QueryBuilderPreviewData,
|
90
|
-
buildNonNumericPreviewDataQuery,
|
91
84
|
buildNumericPreviewDataQuery,
|
85
|
+
buildNonNumericPreviewDataQuery,
|
92
86
|
} from './QueryBuilderPreviewDataHelper.js';
|
93
|
-
import { buildGenericLambdaFunctionInstanceValue } from './QueryBuilderValueSpecificationBuilderHelper.js';
|
94
|
-
import { LambdaEditorState } from '@finos/legend-application';
|
95
87
|
|
96
88
|
export enum QUERY_BUILDER_PROJECTION_DND_TYPE {
|
97
89
|
PROJECTION_COLUMN = 'PROJECTION_COLUMN',
|
@@ -380,7 +372,10 @@ export class QueryBuilderProjectionState {
|
|
380
372
|
aggregationState: QueryBuilderAggregationState;
|
381
373
|
isConvertDerivationProjectionObjects = false;
|
382
374
|
|
383
|
-
constructor(
|
375
|
+
constructor(
|
376
|
+
queryBuilderState: QueryBuilderState,
|
377
|
+
operators: QueryBuilderAggregateOperator[],
|
378
|
+
) {
|
384
379
|
makeAutoObservable(this, {
|
385
380
|
queryBuilderState: false,
|
386
381
|
removeColumn: action,
|
@@ -390,18 +385,7 @@ export class QueryBuilderProjectionState {
|
|
390
385
|
});
|
391
386
|
|
392
387
|
this.queryBuilderState = queryBuilderState;
|
393
|
-
this.aggregationState = new QueryBuilderAggregationState(this,
|
394
|
-
new QueryBuilderAggregateOperator_Count(),
|
395
|
-
new QueryBuilderAggregateOperator_DistinctCount(),
|
396
|
-
new QueryBuilderAggregateOperator_Distinct(),
|
397
|
-
new QueryBuilderAggregateOperator_Sum(),
|
398
|
-
new QueryBuilderAggregateOperator_Average(),
|
399
|
-
new QueryBuilderAggregateOperator_Min(),
|
400
|
-
new QueryBuilderAggregateOperator_Max(),
|
401
|
-
new QueryBuilderAggregateOperator_StdDev_Population(),
|
402
|
-
new QueryBuilderAggregateOperator_StdDev_Sample(),
|
403
|
-
new QueryBuilderAggregateOperator_JoinString(),
|
404
|
-
]);
|
388
|
+
this.aggregationState = new QueryBuilderAggregationState(this, operators);
|
405
389
|
}
|
406
390
|
|
407
391
|
*convertDerivationProjectionObjects(): GeneratorFn<void> {
|
@@ -709,13 +693,9 @@ export class QueryBuilderProjectionState {
|
|
709
693
|
case PRIMITIVE_TYPE.FLOAT: {
|
710
694
|
const previewResult =
|
711
695
|
(yield this.queryBuilderState.graphManagerState.graphManager.executeMapping(
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
this.queryBuilderState.querySetupState._class,
|
716
|
-
this.queryBuilderState.graphManagerState.graph,
|
717
|
-
),
|
718
|
-
this.queryBuilderState.graphManagerState,
|
696
|
+
buildNumericPreviewDataQuery(
|
697
|
+
this.queryBuilderState,
|
698
|
+
propertyExpression,
|
719
699
|
),
|
720
700
|
this.queryBuilderState.querySetupState.mapping,
|
721
701
|
runtime,
|
@@ -752,13 +732,9 @@ export class QueryBuilderProjectionState {
|
|
752
732
|
case PRIMITIVE_TYPE.DATETIME: {
|
753
733
|
const previewResult =
|
754
734
|
(yield this.queryBuilderState.graphManagerState.graphManager.executeMapping(
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
this.queryBuilderState.querySetupState._class,
|
759
|
-
this.queryBuilderState.graphManagerState.graph,
|
760
|
-
),
|
761
|
-
this.queryBuilderState.graphManagerState,
|
735
|
+
buildNonNumericPreviewDataQuery(
|
736
|
+
this.queryBuilderState,
|
737
|
+
propertyExpression,
|
762
738
|
),
|
763
739
|
this.queryBuilderState.querySetupState.mapping,
|
764
740
|
runtime,
|
@@ -795,17 +771,24 @@ export class QueryBuilderProjectionState {
|
|
795
771
|
}
|
796
772
|
|
797
773
|
isValidProjectionState(): boolean {
|
774
|
+
return Boolean(!this.getValidationErrorMessage());
|
775
|
+
}
|
776
|
+
|
777
|
+
getValidationErrorMessage(): string | undefined {
|
798
778
|
if (this.queryBuilderState.fetchStructureState.isProjectionMode()) {
|
799
|
-
// duplicate columns check
|
800
779
|
const hasDuplicatedProjectionColumns = this.columns.some(
|
801
780
|
(column) =>
|
802
781
|
this.columns.filter((c) => c.columnName === column.columnName)
|
803
782
|
.length > 1,
|
804
783
|
);
|
805
|
-
|
784
|
+
if (hasDuplicatedProjectionColumns) {
|
785
|
+
return 'Query has duplicated projection columns';
|
786
|
+
}
|
806
787
|
const hasNoProjectionColumns = this.columns.length === 0;
|
807
|
-
|
788
|
+
if (hasNoProjectionColumns) {
|
789
|
+
return 'Query has no projection columns';
|
790
|
+
}
|
808
791
|
}
|
809
|
-
return
|
792
|
+
return undefined;
|
810
793
|
}
|
811
794
|
}
|