@finos/legend-query-builder 4.10.1 → 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/__lib__/QueryBuilderDocumentation.d.ts +2 -1
- package/lib/__lib__/QueryBuilderDocumentation.d.ts.map +1 -1
- package/lib/__lib__/QueryBuilderDocumentation.js +1 -0
- package/lib/__lib__/QueryBuilderDocumentation.js.map +1 -1
- package/lib/__lib__/QueryBuilderEvent.d.ts +2 -1
- package/lib/__lib__/QueryBuilderEvent.d.ts.map +1 -1
- package/lib/__lib__/QueryBuilderEvent.js +1 -0
- package/lib/__lib__/QueryBuilderEvent.js.map +1 -1
- package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderResultPanel.js +165 -57
- package/lib/components/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +2 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts +22 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.js +24 -0
- package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.js +2 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.js.map +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts +8 -3
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +11 -30
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts +2 -0
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +8 -0
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.js +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts +4 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js +37 -3
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts +1 -4
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js +1 -5
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.d.ts +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js +2 -2
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts +3 -2
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js +9 -0
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js +2 -4
- package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.d.ts +2 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +1 -15
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +3 -44
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +13 -3
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +3 -2
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts +2 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +2 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +2 -2
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +3 -10
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts +1 -1
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/__lib__/QueryBuilderDocumentation.ts +1 -0
- package/src/__lib__/QueryBuilderEvent.ts +1 -0
- package/src/components/QueryBuilderResultPanel.tsx +269 -90
- package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +2 -4
- package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +1 -1
- package/src/graph/QueryBuilderMetaModelConst.ts +25 -0
- package/src/index.ts +9 -2
- package/src/stores/QueryBuilderPreviewDataHelper.ts +2 -4
- package/src/stores/QueryBuilderResultState.ts +17 -34
- package/src/stores/QueryBuilderState.ts +12 -0
- package/src/stores/QueryBuilderTypeaheadHelper.ts +2 -4
- package/src/stores/fetch-structure/tds/QueryBuilderTDSHelper.ts +58 -2
- package/src/stores/fetch-structure/tds/QueryResultSetModifierState.ts +1 -5
- package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.ts +5 -9
- package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.ts +16 -2
- package/src/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.ts +2 -4
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.ts +1 -1
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +1 -50
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +22 -4
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +4 -4
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +1 -1
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +5 -5
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +5 -15
- package/src/stores/fetch-structure/tds/window/QueryBuilderWindowState.ts +1 -1
@@ -17,15 +17,14 @@
|
|
17
17
|
import { action, flow, makeObservable, observable } from 'mobx';
|
18
18
|
import {
|
19
19
|
type GeneratorFn,
|
20
|
-
type ContentType,
|
21
20
|
assertErrorThrown,
|
22
21
|
LogEvent,
|
23
22
|
guaranteeNonNullable,
|
23
|
+
type ContentType,
|
24
24
|
downloadFileUsingDataURI,
|
25
25
|
ActionState,
|
26
26
|
StopWatch,
|
27
27
|
getContentTypeFileExtension,
|
28
|
-
isBoolean,
|
29
28
|
} from '@finos/legend-shared';
|
30
29
|
import type { QueryBuilderState } from './QueryBuilderState.js';
|
31
30
|
import {
|
@@ -38,7 +37,6 @@ import {
|
|
38
37
|
buildRawLambdaFromLambdaFunction,
|
39
38
|
reportGraphAnalytics,
|
40
39
|
extractExecutionResultValues,
|
41
|
-
TDSExecutionResult,
|
42
40
|
} from '@finos/legend-graph';
|
43
41
|
import { buildLambdaFunction } from './QueryBuilderValueSpecificationBuilder.js';
|
44
42
|
import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
|
@@ -50,6 +48,7 @@ import type { LambdaFunctionBuilderOption } from './QueryBuilderValueSpecificati
|
|
50
48
|
import { QueryBuilderTelemetryHelper } from '../__lib__/QueryBuilderTelemetryHelper.js';
|
51
49
|
import { QUERY_BUILDER_EVENT } from '../__lib__/QueryBuilderEvent.js';
|
52
50
|
import { ExecutionPlanState } from './execution-plan/ExecutionPlanState.js';
|
51
|
+
import type { DataGridColumnState } from '@finos/legend-lego/data-grid';
|
53
52
|
|
54
53
|
export const DEFAULT_LIMIT = 1000;
|
55
54
|
|
@@ -69,6 +68,11 @@ export interface QueryBuilderTDSResultCellCoordinate {
|
|
69
68
|
colIndex: number;
|
70
69
|
}
|
71
70
|
|
71
|
+
type QueryBuilderDataGridConfig = {
|
72
|
+
columns: DataGridColumnState[];
|
73
|
+
isPivotModeEnabled: boolean;
|
74
|
+
};
|
75
|
+
|
72
76
|
export class QueryBuilderResultState {
|
73
77
|
readonly queryBuilderState: QueryBuilderState;
|
74
78
|
readonly exportDataState = ActionState.create();
|
@@ -83,12 +87,13 @@ export class QueryBuilderResultState {
|
|
83
87
|
latestRunHashCode?: string | undefined;
|
84
88
|
queryRunPromise: Promise<ExecutionResult> | undefined = undefined;
|
85
89
|
isQueryUsageViewerOpened = false;
|
86
|
-
rowData: Record<string, string | number | boolean | null>[] = [];
|
87
90
|
|
88
91
|
selectedCells: QueryBuilderTDSResultCellData[];
|
89
92
|
mousedOverCell: QueryBuilderTDSResultCellData | null = null;
|
90
93
|
isSelectingCells: boolean;
|
91
94
|
|
95
|
+
gridConfig!: QueryBuilderDataGridConfig;
|
96
|
+
|
92
97
|
constructor(queryBuilderState: QueryBuilderState) {
|
93
98
|
makeObservable(this, {
|
94
99
|
executionResult: observable,
|
@@ -102,6 +107,8 @@ export class QueryBuilderResultState {
|
|
102
107
|
isRunningQuery: observable,
|
103
108
|
isSelectingCells: observable,
|
104
109
|
isQueryUsageViewerOpened: observable,
|
110
|
+
gridConfig: observable,
|
111
|
+
setGridConfig: action,
|
105
112
|
setIsSelectingCells: action,
|
106
113
|
setIsRunningQuery: action,
|
107
114
|
setExecutionResult: action,
|
@@ -113,8 +120,6 @@ export class QueryBuilderResultState {
|
|
113
120
|
setQueryRunPromise: action,
|
114
121
|
setIsQueryUsageViewerOpened: action,
|
115
122
|
exportData: flow,
|
116
|
-
getRowData: action,
|
117
|
-
setRowData: action,
|
118
123
|
runQuery: flow,
|
119
124
|
cancelQuery: flow,
|
120
125
|
generatePlan: flow,
|
@@ -122,6 +127,10 @@ export class QueryBuilderResultState {
|
|
122
127
|
this.isSelectingCells = false;
|
123
128
|
|
124
129
|
this.selectedCells = [];
|
130
|
+
this.gridConfig = {
|
131
|
+
columns: [],
|
132
|
+
isPivotModeEnabled: false,
|
133
|
+
};
|
125
134
|
this.queryBuilderState = queryBuilderState;
|
126
135
|
this.executionPlanState = new ExecutionPlanState(
|
127
136
|
this.queryBuilderState.applicationStore,
|
@@ -129,34 +138,8 @@ export class QueryBuilderResultState {
|
|
129
138
|
);
|
130
139
|
}
|
131
140
|
|
132
|
-
|
133
|
-
|
134
|
-
this.executionResult &&
|
135
|
-
this.executionResult instanceof TDSExecutionResult
|
136
|
-
) {
|
137
|
-
const data = this.executionResult.result.rows.map((_row, rowIdx) => {
|
138
|
-
const row: Record<string, string | number | boolean | null> = {};
|
139
|
-
const cols = (this.executionResult as TDSExecutionResult).result
|
140
|
-
.columns;
|
141
|
-
_row.values.forEach((value, colIdx) => {
|
142
|
-
// `ag-grid` shows `false` value as empty string so we have
|
143
|
-
// call `.toString()` to avoid this behavior.
|
144
|
-
// See https://github.com/finos/legend-studio/issues/1008
|
145
|
-
row[cols[colIdx] as string] = isBoolean(value)
|
146
|
-
? String(value)
|
147
|
-
: value;
|
148
|
-
});
|
149
|
-
row.rowNumber = rowIdx;
|
150
|
-
return row;
|
151
|
-
});
|
152
|
-
this.rowData = data;
|
153
|
-
return data;
|
154
|
-
}
|
155
|
-
return [];
|
156
|
-
}
|
157
|
-
|
158
|
-
setRowData(val: Record<string, string | number | boolean | null>[]): void {
|
159
|
-
this.rowData = val;
|
141
|
+
setGridConfig(val: QueryBuilderDataGridConfig): void {
|
142
|
+
this.gridConfig = val;
|
160
143
|
}
|
161
144
|
|
162
145
|
setIsSelectingCells(val: boolean): void {
|
@@ -100,6 +100,7 @@ import {
|
|
100
100
|
type QueryBuilderExecutionContextState,
|
101
101
|
} from './QueryBuilderExecutionContextState.js';
|
102
102
|
import type { QueryBuilderConfig } from '../graph-manager/QueryBuilderConfig.js';
|
103
|
+
import { QUERY_BUILDER_EVENT } from '../__lib__/QueryBuilderEvent.js';
|
103
104
|
|
104
105
|
export abstract class QueryBuilderState implements CommandRegistrar {
|
105
106
|
readonly applicationStore: GenericLegendApplicationStore;
|
@@ -130,6 +131,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
130
131
|
isCheckingEntitlments = false;
|
131
132
|
isCalendarEnabled = false;
|
132
133
|
isQueryChatOpened = false;
|
134
|
+
isAdvancedModeEnabled = false;
|
133
135
|
|
134
136
|
class?: Class | undefined;
|
135
137
|
executionContextState: QueryBuilderExecutionContextState;
|
@@ -165,6 +167,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
165
167
|
executionContextState: observable,
|
166
168
|
class: observable,
|
167
169
|
isQueryChatOpened: observable,
|
170
|
+
isAdvancedModeEnabled: observable,
|
168
171
|
|
169
172
|
sideBarClassName: computed,
|
170
173
|
isQuerySupported: computed,
|
@@ -177,6 +180,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
177
180
|
setIsCheckingEntitlments: action,
|
178
181
|
setClass: action,
|
179
182
|
setIsQueryChatOpened: action,
|
183
|
+
setIsAdvancedModeEnabled: action,
|
180
184
|
|
181
185
|
resetQueryResult: action,
|
182
186
|
resetQueryContent: action,
|
@@ -259,6 +263,10 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
259
263
|
this.isQueryChatOpened = val;
|
260
264
|
}
|
261
265
|
|
266
|
+
setIsAdvancedModeEnabled(val: boolean): void {
|
267
|
+
this.isAdvancedModeEnabled = val;
|
268
|
+
}
|
269
|
+
|
262
270
|
setInternalize(val: QueryBuilderInternalizeState | undefined): void {
|
263
271
|
this.internalizeState = val;
|
264
272
|
}
|
@@ -555,6 +563,10 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
555
563
|
this.fetchStructureState.initializeWithQuery();
|
556
564
|
} catch (error) {
|
557
565
|
assertErrorThrown(error);
|
566
|
+
this.applicationStore.logService.error(
|
567
|
+
LogEvent.create(QUERY_BUILDER_EVENT.UNSUPPORTED_QUERY_LAUNCH),
|
568
|
+
error,
|
569
|
+
);
|
558
570
|
this.resetQueryResult({ preserveResult: options?.preserveResult });
|
559
571
|
this.resetQueryContent();
|
560
572
|
this.unsupportedQueryState.setLambdaError(error);
|
@@ -58,10 +58,6 @@ import {
|
|
58
58
|
} from '@finos/legend-shared';
|
59
59
|
import { QueryBuilderPostFilterOperator_StartWith } from './fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js';
|
60
60
|
import type { QueryBuilderAggregateColumnState } from './fetch-structure/tds/aggregation/QueryBuilderAggregationState.js';
|
61
|
-
import {
|
62
|
-
getTDSColumnDerivedProperyFromType,
|
63
|
-
type TDS_COLUMN_GETTER,
|
64
|
-
} from './fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js';
|
65
61
|
import {
|
66
62
|
QueryBuilderDerivationProjectionColumnState,
|
67
63
|
QueryBuilderProjectionColumnState,
|
@@ -75,6 +71,7 @@ import {
|
|
75
71
|
import {
|
76
72
|
QUERY_BUILDER_PURE_PATH,
|
77
73
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
74
|
+
type TDS_COLUMN_GETTER,
|
78
75
|
} from '../graph/QueryBuilderMetaModelConst.js';
|
79
76
|
import {
|
80
77
|
functionExpression_setParametersValues,
|
@@ -89,6 +86,7 @@ import {
|
|
89
86
|
DEFAULT_POST_FILTER_LAMBDA_VARIABLE_NAME,
|
90
87
|
} from './QueryBuilderConfig.js';
|
91
88
|
import type { QueryBuilderAggregateOperator } from './fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js';
|
89
|
+
import { getTDSColumnDerivedProperyFromType } from './fetch-structure/tds/QueryBuilderTDSHelper.js';
|
92
90
|
|
93
91
|
const buildPropertyExpressionChainWithDefaultMilestoningDates = (
|
94
92
|
propertyExpression: AbstractPropertyExpression,
|
@@ -15,6 +15,11 @@
|
|
15
15
|
*/
|
16
16
|
|
17
17
|
import {
|
18
|
+
type Type,
|
19
|
+
Enumeration,
|
20
|
+
PRIMITIVE_TYPE,
|
21
|
+
SimpleFunctionExpression,
|
22
|
+
createPrimitiveInstance_String,
|
18
23
|
extractElementNameFromPath,
|
19
24
|
matchFunctionName,
|
20
25
|
} from '@finos/legend-graph';
|
@@ -22,10 +27,13 @@ import {
|
|
22
27
|
guaranteeNonNullable,
|
23
28
|
UnsupportedOperationError,
|
24
29
|
} from '@finos/legend-shared';
|
25
|
-
import {
|
30
|
+
import {
|
31
|
+
COLUMN_SORT_TYPE,
|
32
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
33
|
+
TDS_COLUMN_GETTER,
|
34
|
+
} from '../../../graph/QueryBuilderMetaModelConst.js';
|
26
35
|
import type { QueryBuilderTDSState } from './QueryBuilderTDSState.js';
|
27
36
|
import type { QueryBuilderTDSColumnState } from './QueryBuilderTDSColumnState.js';
|
28
|
-
import { COLUMN_SORT_TYPE } from './QueryResultSetModifierState.js';
|
29
37
|
|
30
38
|
export const findTDSColumnState = (
|
31
39
|
projectionState: QueryBuilderTDSState,
|
@@ -77,3 +85,51 @@ export const getFunctionNameFromTDSSortColumn = (
|
|
77
85
|
);
|
78
86
|
}
|
79
87
|
};
|
88
|
+
|
89
|
+
export const buildTDSSortTypeExpression = (
|
90
|
+
sortType: COLUMN_SORT_TYPE,
|
91
|
+
column: string,
|
92
|
+
): SimpleFunctionExpression => {
|
93
|
+
const sortColumnFunction = new SimpleFunctionExpression(
|
94
|
+
extractElementNameFromPath(
|
95
|
+
sortType === COLUMN_SORT_TYPE.ASC
|
96
|
+
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_ASC
|
97
|
+
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_DESC,
|
98
|
+
),
|
99
|
+
);
|
100
|
+
const sortColumnName = createPrimitiveInstance_String(column);
|
101
|
+
sortColumnFunction.parametersValues[0] = sortColumnName;
|
102
|
+
return sortColumnFunction;
|
103
|
+
};
|
104
|
+
|
105
|
+
export const getTDSColumnDerivedProperyFromType = (
|
106
|
+
type: Type,
|
107
|
+
): TDS_COLUMN_GETTER => {
|
108
|
+
if (type instanceof Enumeration) {
|
109
|
+
return TDS_COLUMN_GETTER.GET_ENUM;
|
110
|
+
}
|
111
|
+
switch (type.path) {
|
112
|
+
case PRIMITIVE_TYPE.STRING:
|
113
|
+
return TDS_COLUMN_GETTER.GET_STRING;
|
114
|
+
case PRIMITIVE_TYPE.NUMBER:
|
115
|
+
return TDS_COLUMN_GETTER.GET_NUMBER;
|
116
|
+
case PRIMITIVE_TYPE.INTEGER:
|
117
|
+
return TDS_COLUMN_GETTER.GET_INTEGER;
|
118
|
+
case PRIMITIVE_TYPE.FLOAT:
|
119
|
+
return TDS_COLUMN_GETTER.GET_FLOAT;
|
120
|
+
case PRIMITIVE_TYPE.DECIMAL:
|
121
|
+
return TDS_COLUMN_GETTER.GET_DECIMAL;
|
122
|
+
case PRIMITIVE_TYPE.DATE:
|
123
|
+
return TDS_COLUMN_GETTER.GET_DATE;
|
124
|
+
case PRIMITIVE_TYPE.DATETIME:
|
125
|
+
return TDS_COLUMN_GETTER.GET_DATETIME;
|
126
|
+
case PRIMITIVE_TYPE.STRICTDATE:
|
127
|
+
return TDS_COLUMN_GETTER.GET_STRICTDATE;
|
128
|
+
case PRIMITIVE_TYPE.BOOLEAN:
|
129
|
+
return TDS_COLUMN_GETTER.GET_BOOLEAN;
|
130
|
+
default:
|
131
|
+
throw new UnsupportedOperationError(
|
132
|
+
`Can't find TDS column derived property name for type: '${type.path}'`,
|
133
|
+
);
|
134
|
+
}
|
135
|
+
};
|
@@ -24,11 +24,7 @@ import {
|
|
24
24
|
} from '@finos/legend-shared';
|
25
25
|
import { QUERY_BUILDER_STATE_HASH_STRUCTURE } from '../../QueryBuilderStateHashUtils.js';
|
26
26
|
import type { QueryBuilderTDSColumnState } from './QueryBuilderTDSColumnState.js';
|
27
|
-
|
28
|
-
export enum COLUMN_SORT_TYPE {
|
29
|
-
ASC = 'ASC',
|
30
|
-
DESC = 'DESC',
|
31
|
-
}
|
27
|
+
import { COLUMN_SORT_TYPE } from '../../../graph/QueryBuilderMetaModelConst.js';
|
32
28
|
|
33
29
|
export class SortColumnState implements Hashable {
|
34
30
|
columnState: QueryBuilderTDSColumnState;
|
@@ -14,11 +14,7 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import {
|
18
|
-
uuid,
|
19
|
-
guaranteeNonNullable,
|
20
|
-
type Hashable,
|
21
|
-
} from '@finos/legend-shared';
|
17
|
+
import { uuid, type Hashable } from '@finos/legend-shared';
|
22
18
|
import type {
|
23
19
|
AbstractPropertyExpression,
|
24
20
|
PureModel,
|
@@ -82,10 +78,10 @@ export abstract class QueryBuilderAggregateOperator implements Hashable {
|
|
82
78
|
* Returns the expected return type of the operator.
|
83
79
|
* defaults to using the return type of the projection column state which is being aggregated.
|
84
80
|
*/
|
85
|
-
getReturnType(
|
86
|
-
|
87
|
-
|
88
|
-
);
|
81
|
+
getReturnType(
|
82
|
+
aggregateColumnState: QueryBuilderAggregateColumnState,
|
83
|
+
): Type | undefined {
|
84
|
+
return aggregateColumnState.projectionColumnState.getColumnType();
|
89
85
|
}
|
90
86
|
|
91
87
|
abstract get hashCode(): string;
|
@@ -25,7 +25,10 @@ import type { Type } from '@finos/legend-graph';
|
|
25
25
|
import { DEFAULT_LAMBDA_VARIABLE_NAME } from '../../../QueryBuilderConfig.js';
|
26
26
|
import type { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
27
27
|
import type { QueryBuilderAggregateOperator } from './QueryBuilderAggregateOperator.js';
|
28
|
-
import
|
28
|
+
import {
|
29
|
+
QueryBuilderDerivationProjectionColumnState,
|
30
|
+
type QueryBuilderProjectionColumnState,
|
31
|
+
} from '../projection/QueryBuilderProjectionColumnState.js';
|
29
32
|
import { QUERY_BUILDER_STATE_HASH_STRUCTURE } from '../../../QueryBuilderStateHashUtils.js';
|
30
33
|
import { QueryBuilderTDSColumnState } from '../QueryBuilderTDSColumnState.js';
|
31
34
|
import type { QueryBuilderAggregateCalendarFunction } from './QueryBuilderAggregateCalendarFunction.js';
|
@@ -58,6 +61,7 @@ export class QueryBuilderAggregateColumnState
|
|
58
61
|
setLambdaParameterName: action,
|
59
62
|
setOperator: action,
|
60
63
|
setCalendarFunction: action,
|
64
|
+
handleUsedPostFilterType: action,
|
61
65
|
hashCode: computed,
|
62
66
|
});
|
63
67
|
|
@@ -88,10 +92,20 @@ export class QueryBuilderAggregateColumnState
|
|
88
92
|
this.operator = val;
|
89
93
|
}
|
90
94
|
|
91
|
-
getColumnType(): Type {
|
95
|
+
getColumnType(): Type | undefined {
|
92
96
|
return this.operator.getReturnType(this);
|
93
97
|
}
|
94
98
|
|
99
|
+
handleUsedPostFilterType(type: Type): void {
|
100
|
+
if (
|
101
|
+
this.getColumnType() === undefined &&
|
102
|
+
this.projectionColumnState instanceof
|
103
|
+
QueryBuilderDerivationProjectionColumnState
|
104
|
+
) {
|
105
|
+
this.projectionColumnState.setReturnType(type);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
95
109
|
get hashCode(): string {
|
96
110
|
return hashArray([
|
97
111
|
QUERY_BUILDER_STATE_HASH_STRUCTURE.AGGREGATE_COLUMN_STATE,
|
@@ -26,6 +26,7 @@ import {
|
|
26
26
|
type Type,
|
27
27
|
Enumeration,
|
28
28
|
Multiplicity,
|
29
|
+
PrimitiveType,
|
29
30
|
} from '@finos/legend-graph';
|
30
31
|
import {
|
31
32
|
assertTrue,
|
@@ -169,10 +170,7 @@ export class QueryBuilderAggregateOperator_DistinctCount
|
|
169
170
|
override getReturnType(
|
170
171
|
aggregateColumnState: QueryBuilderAggregateColumnState,
|
171
172
|
): Type {
|
172
|
-
|
173
|
-
aggregateColumnState.aggregationState.tdsState.queryBuilderState
|
174
|
-
.graphManagerState.graph;
|
175
|
-
return graph.getType(PRIMITIVE_TYPE.INTEGER);
|
173
|
+
return PrimitiveType.INTEGER;
|
176
174
|
}
|
177
175
|
|
178
176
|
get hashCode(): string {
|
@@ -23,8 +23,8 @@ import { type Hashable, uuid } from '@finos/legend-shared';
|
|
23
23
|
import type {
|
24
24
|
PostFilterConditionState,
|
25
25
|
QueryBuilderPostFilterState,
|
26
|
-
TDS_COLUMN_GETTER,
|
27
26
|
} from './QueryBuilderPostFilterState.js';
|
27
|
+
import type { TDS_COLUMN_GETTER } from '../../../../graph/QueryBuilderMetaModelConst.js';
|
28
28
|
|
29
29
|
export abstract class QueryBuilderPostFilterOperator implements Hashable {
|
30
30
|
readonly uuid = uuid();
|
@@ -22,8 +22,6 @@ import {
|
|
22
22
|
type ExecutionResult,
|
23
23
|
type VariableExpression,
|
24
24
|
type SimpleFunctionExpression,
|
25
|
-
Enumeration,
|
26
|
-
PRIMITIVE_TYPE,
|
27
25
|
observe_ValueSpecification,
|
28
26
|
PrimitiveType,
|
29
27
|
CollectionInstanceValue,
|
@@ -38,7 +36,6 @@ import {
|
|
38
36
|
guaranteeNonNullable,
|
39
37
|
guaranteeType,
|
40
38
|
IllegalStateError,
|
41
|
-
UnsupportedOperationError,
|
42
39
|
uuid,
|
43
40
|
filterByType,
|
44
41
|
ActionState,
|
@@ -78,6 +75,7 @@ import {
|
|
78
75
|
isValueExpressionReferencedInValue,
|
79
76
|
} from '../../../QueryBuilderValueSpecificationHelper.js';
|
80
77
|
import { buildtdsPropertyExpressionFromColState } from './operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
78
|
+
import { TDS_COLUMN_GETTER } from '../../../../graph/QueryBuilderMetaModelConst.js';
|
81
79
|
|
82
80
|
export enum QUERY_BUILDER_POST_FILTER_DND_TYPE {
|
83
81
|
GROUP_CONDITION = 'GROUP_CONDITION',
|
@@ -85,53 +83,6 @@ export enum QUERY_BUILDER_POST_FILTER_DND_TYPE {
|
|
85
83
|
BLANK_CONDITION = 'BLANK_CONDITION',
|
86
84
|
}
|
87
85
|
|
88
|
-
export enum TDS_COLUMN_GETTER {
|
89
|
-
GET_STRING = 'getString',
|
90
|
-
GET_NUMBER = 'getNumber',
|
91
|
-
GET_INTEGER = 'getInteger',
|
92
|
-
GET_FLOAT = 'getFloat',
|
93
|
-
GET_DECIMAL = 'getDecimal',
|
94
|
-
GET_DATE = 'getDate',
|
95
|
-
GET_DATETIME = 'getDateTime',
|
96
|
-
GET_STRICTDATE = 'getStrictDate',
|
97
|
-
GET_BOOLEAN = 'getBoolean',
|
98
|
-
GET_ENUM = 'getEnum',
|
99
|
-
IS_NULL = 'isNull',
|
100
|
-
IS_NOT_NULL = 'isNotNull',
|
101
|
-
}
|
102
|
-
|
103
|
-
export const getTDSColumnDerivedProperyFromType = (
|
104
|
-
type: Type,
|
105
|
-
): TDS_COLUMN_GETTER => {
|
106
|
-
if (type instanceof Enumeration) {
|
107
|
-
return TDS_COLUMN_GETTER.GET_ENUM;
|
108
|
-
}
|
109
|
-
switch (type.path) {
|
110
|
-
case PRIMITIVE_TYPE.STRING:
|
111
|
-
return TDS_COLUMN_GETTER.GET_STRING;
|
112
|
-
case PRIMITIVE_TYPE.NUMBER:
|
113
|
-
return TDS_COLUMN_GETTER.GET_NUMBER;
|
114
|
-
case PRIMITIVE_TYPE.INTEGER:
|
115
|
-
return TDS_COLUMN_GETTER.GET_INTEGER;
|
116
|
-
case PRIMITIVE_TYPE.FLOAT:
|
117
|
-
return TDS_COLUMN_GETTER.GET_FLOAT;
|
118
|
-
case PRIMITIVE_TYPE.DECIMAL:
|
119
|
-
return TDS_COLUMN_GETTER.GET_DECIMAL;
|
120
|
-
case PRIMITIVE_TYPE.DATE:
|
121
|
-
return TDS_COLUMN_GETTER.GET_DATE;
|
122
|
-
case PRIMITIVE_TYPE.DATETIME:
|
123
|
-
return TDS_COLUMN_GETTER.GET_DATETIME;
|
124
|
-
case PRIMITIVE_TYPE.STRICTDATE:
|
125
|
-
return TDS_COLUMN_GETTER.GET_STRICTDATE;
|
126
|
-
case PRIMITIVE_TYPE.BOOLEAN:
|
127
|
-
return TDS_COLUMN_GETTER.GET_BOOLEAN;
|
128
|
-
default:
|
129
|
-
throw new UnsupportedOperationError(
|
130
|
-
`Can't find TDS column derived property name for type: '${type.path}'`,
|
131
|
-
);
|
132
|
-
}
|
133
|
-
};
|
134
|
-
|
135
86
|
export const getTypeFromDerivedProperty = (
|
136
87
|
derivedProperty: TDS_COLUMN_GETTER,
|
137
88
|
graph: PureModel,
|
@@ -36,24 +36,29 @@ import {
|
|
36
36
|
} from '@finos/legend-shared';
|
37
37
|
import { QueryBuilderDerivationProjectionColumnState } from '../projection/QueryBuilderProjectionColumnState.js';
|
38
38
|
import type { QueryBuilderTDSColumnState } from '../QueryBuilderTDSColumnState.js';
|
39
|
-
import {
|
39
|
+
import {
|
40
|
+
getTDSColumnDerivedProperyFromType,
|
41
|
+
getTDSColumnState,
|
42
|
+
} from '../QueryBuilderTDSHelper.js';
|
40
43
|
import type { QueryBuilderPostFilterOperator } from './QueryBuilderPostFilterOperator.js';
|
41
44
|
import {
|
42
45
|
type QueryBuilderPostFilterState,
|
43
|
-
getTDSColumnDerivedProperyFromType,
|
44
46
|
PostFilterConditionState,
|
45
47
|
QueryBuilderPostFilterTreeConditionNodeData,
|
46
48
|
QueryBuilderPostFilterTreeGroupNodeData,
|
47
|
-
TDS_COLUMN_GETTER,
|
48
49
|
getTypeFromDerivedProperty,
|
49
50
|
PostFilterValueSpecConditionValueState,
|
50
51
|
PostFilterTDSColumnValueConditionValueState,
|
51
52
|
} from './QueryBuilderPostFilterState.js';
|
52
|
-
import {
|
53
|
+
import {
|
54
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
55
|
+
TDS_COLUMN_GETTER,
|
56
|
+
} from '../../../../graph/QueryBuilderMetaModelConst.js';
|
53
57
|
import type { QueryBuilderState } from '../../../QueryBuilderState.js';
|
54
58
|
import { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
55
59
|
import { toGroupOperation } from '../../../QueryBuilderGroupOperationHelper.js';
|
56
60
|
import { simplifyValueExpression } from '../../../QueryBuilderValueSpecificationHelper.js';
|
61
|
+
import { QueryBuilderAggregateColumnState } from '../aggregation/QueryBuilderAggregationState.js';
|
57
62
|
|
58
63
|
const findProjectionColumnState = (
|
59
64
|
propertyExpression: AbstractPropertyExpression,
|
@@ -93,6 +98,19 @@ const findProjectionColumnState = (
|
|
93
98
|
columnState.setReturnType(type);
|
94
99
|
}
|
95
100
|
return columnState;
|
101
|
+
} else if (
|
102
|
+
columnState instanceof QueryBuilderAggregateColumnState &&
|
103
|
+
columnState.projectionColumnState instanceof
|
104
|
+
QueryBuilderDerivationProjectionColumnState
|
105
|
+
) {
|
106
|
+
const type = getTypeFromDerivedProperty(
|
107
|
+
tdsColumnGetter,
|
108
|
+
postFilterState.tdsState.queryBuilderState.graphManagerState.graph,
|
109
|
+
);
|
110
|
+
if (type) {
|
111
|
+
columnState.handleUsedPostFilterType(type);
|
112
|
+
}
|
113
|
+
return columnState;
|
96
114
|
}
|
97
115
|
const columnType = guaranteeNonNullable(columnState.getColumnType());
|
98
116
|
assertTrue(
|
@@ -31,13 +31,13 @@ import {
|
|
31
31
|
} from '@finos/legend-graph';
|
32
32
|
import { guaranteeNonNullable } from '@finos/legend-shared';
|
33
33
|
import type { QueryBuilderPostFilterOperator } from '../QueryBuilderPostFilterOperator.js';
|
34
|
+
import { type PostFilterConditionState } from '../QueryBuilderPostFilterState.js';
|
34
35
|
import {
|
35
|
-
|
36
|
+
QUERY_BUILDER_PURE_PATH,
|
36
37
|
type TDS_COLUMN_GETTER,
|
37
|
-
|
38
|
-
} from '../QueryBuilderPostFilterState.js';
|
39
|
-
import { QUERY_BUILDER_PURE_PATH } from '../../../../../graph/QueryBuilderMetaModelConst.js';
|
38
|
+
} from '../../../../../graph/QueryBuilderMetaModelConst.js';
|
40
39
|
import type { QueryBuilderTDSColumnState } from '../../QueryBuilderTDSColumnState.js';
|
40
|
+
import { getTDSColumnDerivedProperyFromType } from '../../QueryBuilderTDSHelper.js';
|
41
41
|
|
42
42
|
export const buildtdsPropertyExpressionFromColState = (
|
43
43
|
filterConditionState: PostFilterConditionState,
|
@@ -26,7 +26,6 @@ import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBui
|
|
26
26
|
import {
|
27
27
|
type PostFilterConditionState,
|
28
28
|
type QueryBuilderPostFilterState,
|
29
|
-
TDS_COLUMN_GETTER,
|
30
29
|
PostFilterValueSpecConditionValueState,
|
31
30
|
} from '../QueryBuilderPostFilterState.js';
|
32
31
|
import { QueryBuilderSimpleProjectionColumnState } from '../../projection/QueryBuilderProjectionColumnState.js';
|
@@ -34,6 +33,7 @@ import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOper
|
|
34
33
|
import { isPropertyExpressionChainOptional } from '../../../../QueryBuilderValueSpecificationHelper.js';
|
35
34
|
import { type Hashable, hashArray } from '@finos/legend-shared';
|
36
35
|
import { QUERY_BUILDER_STATE_HASH_STRUCTURE } from '../../../../QueryBuilderStateHashUtils.js';
|
36
|
+
import { TDS_COLUMN_GETTER } from '../../../../../graph/QueryBuilderMetaModelConst.js';
|
37
37
|
|
38
38
|
export class QueryBuilderPostFilterOperator_IsEmpty
|
39
39
|
extends QueryBuilderPostFilterOperator
|
@@ -37,7 +37,10 @@ import {
|
|
37
37
|
isNonNullable,
|
38
38
|
returnUndefOnError,
|
39
39
|
} from '@finos/legend-shared';
|
40
|
-
import {
|
40
|
+
import {
|
41
|
+
COLUMN_SORT_TYPE,
|
42
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
43
|
+
} from '../../../../graph/QueryBuilderMetaModelConst.js';
|
41
44
|
import type { QueryBuilderState } from '../../../QueryBuilderState.js';
|
42
45
|
import { QueryBuilderValueSpecificationProcessor } from '../../../QueryBuilderStateBuilder.js';
|
43
46
|
import {
|
@@ -51,10 +54,7 @@ import {
|
|
51
54
|
QueryBuilderSimpleProjectionColumnState,
|
52
55
|
} from './QueryBuilderProjectionColumnState.js';
|
53
56
|
import { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
54
|
-
import {
|
55
|
-
COLUMN_SORT_TYPE,
|
56
|
-
SortColumnState,
|
57
|
-
} from '../QueryResultSetModifierState.js';
|
57
|
+
import { SortColumnState } from '../QueryResultSetModifierState.js';
|
58
58
|
|
59
59
|
export const processTDSProjectExpression = (
|
60
60
|
expression: SimpleFunctionExpression,
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts
CHANGED
@@ -40,7 +40,6 @@ import {
|
|
40
40
|
} from './QueryBuilderProjectionColumnState.js';
|
41
41
|
import type { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
42
42
|
import {
|
43
|
-
COLUMN_SORT_TYPE,
|
44
43
|
type QueryResultSetModifierState,
|
45
44
|
type SortColumnState,
|
46
45
|
} from '../QueryResultSetModifierState.js';
|
@@ -49,24 +48,15 @@ import { buildGenericLambdaFunctionInstanceValue } from '../../../QueryBuilderVa
|
|
49
48
|
import { buildPropertyExpressionChain } from '../../../QueryBuilderValueSpecificationBuilderHelper.js';
|
50
49
|
import { appendOLAPGroupByState } from '../window/QueryBuilderWindowValueSpecificationBuilder.js';
|
51
50
|
import { appendPostFilter } from '../post-filter/QueryBuilderPostFilterValueSpecificationBuilder.js';
|
51
|
+
import { buildTDSSortTypeExpression } from '../QueryBuilderTDSHelper.js';
|
52
52
|
|
53
53
|
const buildSortExpression = (
|
54
54
|
sortColumnState: SortColumnState,
|
55
|
-
): SimpleFunctionExpression =>
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_ASC
|
60
|
-
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_DESC,
|
61
|
-
),
|
55
|
+
): SimpleFunctionExpression =>
|
56
|
+
buildTDSSortTypeExpression(
|
57
|
+
sortColumnState.sortType,
|
58
|
+
sortColumnState.columnState.columnName,
|
62
59
|
);
|
63
|
-
const sortColumnName = new PrimitiveInstanceValue(
|
64
|
-
GenericTypeExplicitReference.create(new GenericType(PrimitiveType.STRING)),
|
65
|
-
);
|
66
|
-
sortColumnName.values = [sortColumnState.columnState.columnName];
|
67
|
-
sortColumnFunction.parametersValues[0] = sortColumnName;
|
68
|
-
return sortColumnFunction;
|
69
|
-
};
|
70
60
|
|
71
61
|
const appendResultSetModifier = (
|
72
62
|
resultModifierState: QueryResultSetModifierState,
|
@@ -29,8 +29,8 @@ import { DEFAULT_LAMBDA_VARIABLE_NAME } from '../../../QueryBuilderConfig.js';
|
|
29
29
|
import type { QueryBuilderProjectionColumnDragSource } from '../projection/QueryBuilderProjectionColumnState.js';
|
30
30
|
import { QueryBuilderTDSColumnState } from '../QueryBuilderTDSColumnState.js';
|
31
31
|
import type { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
32
|
-
import type { COLUMN_SORT_TYPE } from '../QueryResultSetModifierState.js';
|
33
32
|
import type { QueryBuilderTDS_WindowOperator } from './operators/QueryBuilderTDS_WindowOperator.js';
|
33
|
+
import type { COLUMN_SORT_TYPE } from '../../../../graph/QueryBuilderMetaModelConst.js';
|
34
34
|
|
35
35
|
export const QUERY_BUILDER_WINDOW_COLUMN_DND_TYPE = 'WINDOW_COLUMN';
|
36
36
|
|