@finos/legend-query-builder 4.19.30 → 4.19.32
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/__lib__/QueryBuilderTelemetryHelper.d.ts +1 -0
- package/lib/__lib__/QueryBuilderTelemetryHelper.d.ts.map +1 -1
- package/lib/__lib__/QueryBuilderTelemetryHelper.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +145 -16
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +17 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts +1 -0
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.js +5 -5
- package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
- package/lib/components/shared/CustomDatePicker.d.ts +1 -0
- package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
- package/lib/components/shared/CustomDatePicker.js +9 -7
- package/lib/components/shared/CustomDatePicker.js.map +1 -1
- package/lib/data-access-overview.css +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts +6 -0
- package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.js +7 -0
- package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.d.ts.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 +10 -0
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.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/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +4 -3
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.js +6 -2
- package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
- package/lib/stores/QueryBuilderStateHashUtils.d.ts +2 -0
- package/lib/stores/QueryBuilderStateHashUtils.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateHashUtils.js +2 -0
- package/lib/stores/QueryBuilderStateHashUtils.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 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.js +2 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.js.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts +46 -3
- package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkState.js +133 -12
- package/lib/stores/watermark/QueryBuilderWatermarkState.js.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.d.ts.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.js +48 -6
- package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.js.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.d.ts +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.js +45 -11
- package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.js.map +1 -1
- package/package.json +11 -11
- package/src/__lib__/QueryBuilderTelemetryHelper.ts +1 -0
- package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +333 -12
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +26 -5
- package/src/components/shared/BasicValueSpecificationEditor.tsx +17 -9
- package/src/components/shared/CustomDatePicker.tsx +10 -6
- package/src/graph/QueryBuilderMetaModelConst.ts +9 -0
- package/src/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +14 -0
- package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +38 -0
- package/src/stores/QueryBuilderState.ts +3 -1
- package/src/stores/QueryBuilderStateBuilder.ts +5 -4
- package/src/stores/QueryBuilderStateHashUtils.ts +2 -0
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +2 -1
- package/src/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.ts +2 -1
- package/src/stores/watermark/QueryBuilderWatermarkState.ts +164 -12
- package/src/stores/watermark/QueryBuilderWatermarkStateBuilder.ts +111 -5
- package/src/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.ts +97 -17
|
@@ -1365,6 +1365,44 @@ export const V1_buildGroupByFunctionExpression = (
|
|
|
1365
1365
|
);
|
|
1366
1366
|
};
|
|
1367
1367
|
|
|
1368
|
+
export const V1_buildDataDNSWatermarkFunctionExpression = (
|
|
1369
|
+
functionName: string,
|
|
1370
|
+
parameters: V1_ValueSpecification[],
|
|
1371
|
+
openVariables: string[],
|
|
1372
|
+
compileContext: V1_GraphBuilderContext,
|
|
1373
|
+
processingContext: V1_ProcessingContext,
|
|
1374
|
+
): SimpleFunctionExpression | undefined => {
|
|
1375
|
+
assertTrue(
|
|
1376
|
+
parameters.length === 5,
|
|
1377
|
+
`Can't build forDataDNSWatermark() expression: forDataDNSWatermark() expects 5 arguments`,
|
|
1378
|
+
);
|
|
1379
|
+
const builtParameters = parameters.map((parameter) =>
|
|
1380
|
+
guaranteeNonNullable(parameter).accept_ValueSpecificationVisitor(
|
|
1381
|
+
new V1_ValueSpecificationBuilder(
|
|
1382
|
+
compileContext,
|
|
1383
|
+
processingContext,
|
|
1384
|
+
openVariables,
|
|
1385
|
+
),
|
|
1386
|
+
),
|
|
1387
|
+
);
|
|
1388
|
+
const precedingExpression = guaranteeNonNullable(builtParameters[0]);
|
|
1389
|
+
assertNonNullable(
|
|
1390
|
+
precedingExpression.genericType,
|
|
1391
|
+
`Can't build forDataDNSWatermark() expression: preceding expression return type is missing`,
|
|
1392
|
+
);
|
|
1393
|
+
|
|
1394
|
+
const expression = V1_buildBaseSimpleFunctionExpression(
|
|
1395
|
+
builtParameters,
|
|
1396
|
+
functionName,
|
|
1397
|
+
compileContext,
|
|
1398
|
+
);
|
|
1399
|
+
|
|
1400
|
+
expression.genericType = precedingExpression.genericType;
|
|
1401
|
+
expression.multiplicity = precedingExpression.multiplicity;
|
|
1402
|
+
|
|
1403
|
+
return expression;
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1368
1406
|
export const V1_buildWatermarkFunctionExpression = (
|
|
1369
1407
|
functionName: string,
|
|
1370
1408
|
parameters: V1_ValueSpecification[],
|
|
@@ -659,7 +659,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
|
659
659
|
constantCount: this.constantState.constants.length,
|
|
660
660
|
hasFilter: !this.filterState.isEmpty,
|
|
661
661
|
filterNodeCount: this.filterState.nodes.size,
|
|
662
|
-
watermarkEnabled: this.watermarkState.
|
|
662
|
+
watermarkEnabled: this.watermarkState.isEnabled,
|
|
663
663
|
milestoningKind: this.milestoningState.milestoningKind,
|
|
664
664
|
};
|
|
665
665
|
if (
|
|
@@ -1315,11 +1315,13 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
|
1315
1315
|
get allValidationIssues(): string[] {
|
|
1316
1316
|
return this.fetchStructureState.implementation.allValidationIssues.concat(
|
|
1317
1317
|
this.filterState.allValidationIssues,
|
|
1318
|
+
this.watermarkState.validationIssues,
|
|
1318
1319
|
);
|
|
1319
1320
|
}
|
|
1320
1321
|
|
|
1321
1322
|
get canBuildQuery(): boolean {
|
|
1322
1323
|
return (
|
|
1324
|
+
this.watermarkState.isValid &&
|
|
1323
1325
|
!this.filterState.hasInvalidFilterValues &&
|
|
1324
1326
|
!this.filterState.hasInvalidDerivedPropertyParameters &&
|
|
1325
1327
|
!this.fetchStructureState.implementation.hasInvalidFilterValues &&
|
|
@@ -669,20 +669,21 @@ export class QueryBuilderValueSpecificationProcessor
|
|
|
669
669
|
} else if (
|
|
670
670
|
matchFunctionName(precedingExpression.functionName, [
|
|
671
671
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
|
|
672
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.DATA_DNS_WATERMARK,
|
|
672
673
|
])
|
|
673
674
|
) {
|
|
674
675
|
processFilterExpression(valueSpecification, this.queryBuilderState);
|
|
675
676
|
return;
|
|
676
677
|
} else {
|
|
677
678
|
throw new UnsupportedOperationError(
|
|
678
|
-
`Can't process filter() expression: only support filter() immediately following getAll() or project()/forWatermark()/groupBy()/olapGroupBy()`,
|
|
679
|
+
`Can't process filter() expression: only support filter() immediately following getAll() or project()/forWatermark()/forDataDNSWatermark()/groupBy()/olapGroupBy()`,
|
|
679
680
|
);
|
|
680
681
|
}
|
|
681
682
|
} else if (
|
|
682
|
-
matchFunctionName(
|
|
683
|
-
functionName,
|
|
683
|
+
matchFunctionName(functionName, [
|
|
684
684
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
|
|
685
|
-
|
|
685
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.DATA_DNS_WATERMARK,
|
|
686
|
+
])
|
|
686
687
|
) {
|
|
687
688
|
processWatermarkExpression(
|
|
688
689
|
valueSpecification,
|
|
@@ -70,6 +70,8 @@ export enum QUERY_BUILDER_STATE_HASH_STRUCTURE {
|
|
|
70
70
|
|
|
71
71
|
// watermark state
|
|
72
72
|
WATERMARK_STATE = 'WATERMARK_STATE',
|
|
73
|
+
STANDARD_WATERMARK_STATE = 'STANDARD_WATERMARK_STATE',
|
|
74
|
+
DATA_DNS_WATERMARK_STATE = 'DATA_DNS_WATERMARK_STATE',
|
|
73
75
|
|
|
74
76
|
// OLAPGroup state
|
|
75
77
|
TDS_WINDOW_GROUPBY_STATE = 'TDS_WINDOW_STATE',
|
|
@@ -87,8 +87,9 @@ const validateTDSProjectPrecedingExpression = (
|
|
|
87
87
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
|
88
88
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
|
89
89
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
|
|
90
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.DATA_DNS_WATERMARK,
|
|
90
91
|
]),
|
|
91
|
-
`Can't process project() expression: only support project() immediately following either getAll(), filter(), or
|
|
92
|
+
`Can't process project() expression: only support project() immediately following either getAll(), filter(), forWatermark(), or forDataDNSWatermark()`,
|
|
92
93
|
);
|
|
93
94
|
QueryBuilderValueSpecificationProcessor.process(
|
|
94
95
|
precedingExpression,
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderTypedProjectionStateBuilder.ts
CHANGED
|
@@ -64,8 +64,9 @@ export const processTypedTDSProjectExpression = (
|
|
|
64
64
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
|
65
65
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
|
66
66
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
|
|
67
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.DATA_DNS_WATERMARK,
|
|
67
68
|
]),
|
|
68
|
-
`Can't process typed project() expression: only support typed project() immediately following either getAll(), filter(), or
|
|
69
|
+
`Can't process typed project() expression: only support typed project() immediately following either getAll(), filter(), forWatermark(), or forDataDNSWatermark()`,
|
|
69
70
|
);
|
|
70
71
|
} else if (!(_precedingExpression instanceof AccessorInstanceValue)) {
|
|
71
72
|
throw new Error(
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
type ValueSpecification,
|
|
19
|
-
|
|
19
|
+
VariableExpression,
|
|
20
20
|
observe_ValueSpecification,
|
|
21
21
|
GenericTypeExplicitReference,
|
|
22
22
|
GenericType,
|
|
@@ -25,18 +25,132 @@ import {
|
|
|
25
25
|
} from '@finos/legend-graph';
|
|
26
26
|
import { type Hashable, hashArray } from '@finos/legend-shared';
|
|
27
27
|
import { makeObservable, observable, action, computed } from 'mobx';
|
|
28
|
+
import { DATA_DNS_ENV } from '../../graph/QueryBuilderMetaModelConst.js';
|
|
28
29
|
import { QUERY_BUILDER_STATE_HASH_STRUCTURE } from '../QueryBuilderStateHashUtils.js';
|
|
29
30
|
import type { QueryBuilderState } from '../QueryBuilderState.js';
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
isValidInstanceValue,
|
|
33
|
+
isValueExpressionReferencedInValue,
|
|
34
|
+
} from '../QueryBuilderValueSpecificationHelper.js';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A query has at most one watermark, either the standard `forWatermark()` or the Data DNS
|
|
38
|
+
* `forDataDNSWatermark()`: the watermark state holds a single `QueryBuilderWatermark`.
|
|
39
|
+
*/
|
|
40
|
+
export abstract class QueryBuilderWatermark implements Hashable {
|
|
41
|
+
abstract get hashCode(): string;
|
|
42
|
+
|
|
43
|
+
abstract isVariableUsed(variable: VariableExpression): boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Watermark given as a single value, i.e. `forWatermark()`.
|
|
48
|
+
*/
|
|
49
|
+
export class QueryBuilderStandardWatermark extends QueryBuilderWatermark {
|
|
50
|
+
value: ValueSpecification;
|
|
51
|
+
|
|
52
|
+
constructor(value: ValueSpecification) {
|
|
53
|
+
super();
|
|
54
|
+
makeObservable(this, {
|
|
55
|
+
value: observable,
|
|
56
|
+
hashCode: computed,
|
|
57
|
+
});
|
|
58
|
+
this.value = value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
isVariableUsed(variable: VariableExpression): boolean {
|
|
62
|
+
return isValueExpressionReferencedInValue(variable, this.value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get hashCode(): string {
|
|
66
|
+
return hashArray([
|
|
67
|
+
QUERY_BUILDER_STATE_HASH_STRUCTURE.STANDARD_WATERMARK_STATE,
|
|
68
|
+
this.value,
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Watermark resolved through the Data DNS Watermark Resolver, i.e. `forDataDNSWatermark()`.
|
|
75
|
+
*/
|
|
76
|
+
export class QueryBuilderDataDNSWatermark extends QueryBuilderWatermark {
|
|
77
|
+
env: DATA_DNS_ENV = DATA_DNS_ENV.PROD;
|
|
78
|
+
registryUri = '';
|
|
79
|
+
// the business date parameter of the query, which the watermark follows, or a date of the user's own
|
|
80
|
+
date: PrimitiveInstanceValue | VariableExpression | undefined;
|
|
81
|
+
milestone = '';
|
|
82
|
+
|
|
83
|
+
constructor() {
|
|
84
|
+
super();
|
|
85
|
+
makeObservable(this, {
|
|
86
|
+
env: observable,
|
|
87
|
+
registryUri: observable,
|
|
88
|
+
date: observable,
|
|
89
|
+
milestone: observable,
|
|
90
|
+
setEnv: action,
|
|
91
|
+
setRegistryUri: action,
|
|
92
|
+
setDate: action,
|
|
93
|
+
setMilestone: action,
|
|
94
|
+
hashCode: computed,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
setEnv(val: DATA_DNS_ENV): void {
|
|
99
|
+
this.env = val;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setRegistryUri(val: string): void {
|
|
103
|
+
this.registryUri = val;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setDate(val: PrimitiveInstanceValue | VariableExpression | undefined): void {
|
|
107
|
+
this.date = val;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
setMilestone(val: string): void {
|
|
111
|
+
this.milestone = val;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// the business date parameter of the query is given as context: the date can be it only while the query has it
|
|
115
|
+
isValid(businessDateVariable: VariableExpression | undefined): boolean {
|
|
116
|
+
return Boolean(
|
|
117
|
+
this.registryUri.trim() &&
|
|
118
|
+
this.date !== undefined &&
|
|
119
|
+
(this.date instanceof VariableExpression
|
|
120
|
+
? this.date.name === businessDateVariable?.name
|
|
121
|
+
: isValidInstanceValue(this.date)),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
isVariableUsed(variable: VariableExpression): boolean {
|
|
126
|
+
return this.date !== undefined
|
|
127
|
+
? isValueExpressionReferencedInValue(variable, this.date)
|
|
128
|
+
: false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get hashCode(): string {
|
|
132
|
+
return hashArray([
|
|
133
|
+
QUERY_BUILDER_STATE_HASH_STRUCTURE.DATA_DNS_WATERMARK_STATE,
|
|
134
|
+
this.env,
|
|
135
|
+
this.registryUri,
|
|
136
|
+
this.date ?? '',
|
|
137
|
+
this.milestone,
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
31
141
|
|
|
32
142
|
export class QueryBuilderWatermarkState implements Hashable {
|
|
33
143
|
readonly queryBuilderState: QueryBuilderState;
|
|
34
|
-
|
|
144
|
+
watermark?: QueryBuilderWatermark | undefined;
|
|
35
145
|
|
|
36
146
|
constructor(queryBuilderState: QueryBuilderState) {
|
|
37
147
|
makeObservable(this, {
|
|
38
|
-
|
|
39
|
-
|
|
148
|
+
watermark: observable,
|
|
149
|
+
setWatermark: action,
|
|
150
|
+
isEnabled: computed,
|
|
151
|
+
businessDateVariable: computed,
|
|
152
|
+
validationIssues: computed,
|
|
153
|
+
isValid: computed,
|
|
40
154
|
hashCode: computed,
|
|
41
155
|
});
|
|
42
156
|
|
|
@@ -53,22 +167,60 @@ export class QueryBuilderWatermarkState implements Hashable {
|
|
|
53
167
|
return watermarkConstant;
|
|
54
168
|
}
|
|
55
169
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
170
|
+
setWatermark(val: QueryBuilderWatermark | undefined): void {
|
|
171
|
+
if (val instanceof QueryBuilderStandardWatermark) {
|
|
172
|
+
val.value = observe_ValueSpecification(
|
|
173
|
+
val.value,
|
|
174
|
+
this.queryBuilderState.observerContext,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
this.watermark = val;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
get isEnabled(): boolean {
|
|
181
|
+
return this.watermark !== undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The business date of the query, when it is a parameter: the Data DNS watermark uses the parameter
|
|
186
|
+
* itself, so that the watermark follows the value of the parameter.
|
|
187
|
+
*/
|
|
188
|
+
get businessDateVariable(): VariableExpression | undefined {
|
|
189
|
+
const milestoningState = this.queryBuilderState.milestoningState;
|
|
190
|
+
return !milestoningState.isAllVersionsEnabled &&
|
|
191
|
+
milestoningState.businessDate instanceof VariableExpression
|
|
192
|
+
? milestoningState.businessDate
|
|
59
193
|
: undefined;
|
|
60
194
|
}
|
|
61
195
|
|
|
196
|
+
get validationIssues(): string[] {
|
|
197
|
+
const watermark = this.watermark;
|
|
198
|
+
if (
|
|
199
|
+
watermark instanceof QueryBuilderDataDNSWatermark &&
|
|
200
|
+
!watermark.isValid(this.businessDateVariable)
|
|
201
|
+
) {
|
|
202
|
+
return watermark.date instanceof VariableExpression &&
|
|
203
|
+
watermark.date.name !== this.businessDateVariable?.name
|
|
204
|
+
? [
|
|
205
|
+
'Data DNS watermark uses the business date, which must be a date parameter',
|
|
206
|
+
]
|
|
207
|
+
: ['Data DNS watermark is incomplete'];
|
|
208
|
+
}
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
get isValid(): boolean {
|
|
213
|
+
return this.validationIssues.length === 0;
|
|
214
|
+
}
|
|
215
|
+
|
|
62
216
|
isVariableUsed(variable: VariableExpression): boolean {
|
|
63
|
-
return this.
|
|
64
|
-
? isValueExpressionReferencedInValue(variable, this.value)
|
|
65
|
-
: false;
|
|
217
|
+
return this.watermark?.isVariableUsed(variable) ?? false;
|
|
66
218
|
}
|
|
67
219
|
|
|
68
220
|
get hashCode(): string {
|
|
69
221
|
return hashArray([
|
|
70
222
|
QUERY_BUILDER_STATE_HASH_STRUCTURE.WATERMARK_STATE,
|
|
71
|
-
this.
|
|
223
|
+
this.watermark ?? '',
|
|
72
224
|
]);
|
|
73
225
|
}
|
|
74
226
|
}
|
|
@@ -16,14 +16,103 @@
|
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
type LambdaFunction,
|
|
19
|
+
type ValueSpecification,
|
|
20
|
+
CollectionInstanceValue,
|
|
21
|
+
EnumValueInstanceValue,
|
|
22
|
+
PrimitiveInstanceValue,
|
|
23
|
+
PrimitiveType,
|
|
19
24
|
SimpleFunctionExpression,
|
|
25
|
+
VariableExpression,
|
|
20
26
|
matchFunctionName,
|
|
21
27
|
} from '@finos/legend-graph';
|
|
22
|
-
import {
|
|
23
|
-
|
|
28
|
+
import {
|
|
29
|
+
assertTrue,
|
|
30
|
+
guaranteeNonNullable,
|
|
31
|
+
guaranteeType,
|
|
32
|
+
UnsupportedOperationError,
|
|
33
|
+
} from '@finos/legend-shared';
|
|
34
|
+
import {
|
|
35
|
+
DATA_DNS_ENV,
|
|
36
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
|
37
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
|
38
|
+
} from '../../graph/QueryBuilderMetaModelConst.js';
|
|
39
|
+
import {
|
|
40
|
+
QueryBuilderDataDNSWatermark,
|
|
41
|
+
QueryBuilderStandardWatermark,
|
|
42
|
+
} from './QueryBuilderWatermarkState.js';
|
|
24
43
|
import type { QueryBuilderState } from '../QueryBuilderState.js';
|
|
25
44
|
import { QueryBuilderValueSpecificationProcessor } from '../QueryBuilderStateBuilder.js';
|
|
26
45
|
|
|
46
|
+
const extractStringLiteral = (
|
|
47
|
+
value: ValueSpecification | undefined,
|
|
48
|
+
description: string,
|
|
49
|
+
): string => {
|
|
50
|
+
const instance = guaranteeType(
|
|
51
|
+
value,
|
|
52
|
+
PrimitiveInstanceValue,
|
|
53
|
+
`Can't process forDataDNSWatermark() expression: ${description} must be a string literal`,
|
|
54
|
+
);
|
|
55
|
+
return String(guaranteeNonNullable(instance.values[0]));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const processDataDNSWatermarkExpression = (
|
|
59
|
+
expression: SimpleFunctionExpression,
|
|
60
|
+
queryBuilderState: QueryBuilderState,
|
|
61
|
+
): void => {
|
|
62
|
+
const envValue = guaranteeType(
|
|
63
|
+
expression.parametersValues[1],
|
|
64
|
+
EnumValueInstanceValue,
|
|
65
|
+
`Can't process forDataDNSWatermark() expression: environment must be a DataDNSEnv enum value`,
|
|
66
|
+
);
|
|
67
|
+
const envName = guaranteeNonNullable(envValue.values[0]).value.name;
|
|
68
|
+
const env = Object.values(DATA_DNS_ENV).find((e) => e === envName);
|
|
69
|
+
if (!env) {
|
|
70
|
+
throw new UnsupportedOperationError(
|
|
71
|
+
`Can't process forDataDNSWatermark() expression: unsupported environment '${envName}'`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const dataDNSWatermark = new QueryBuilderDataDNSWatermark();
|
|
75
|
+
dataDNSWatermark.setEnv(env);
|
|
76
|
+
dataDNSWatermark.setRegistryUri(
|
|
77
|
+
extractStringLiteral(expression.parametersValues[2], 'registry URI'),
|
|
78
|
+
);
|
|
79
|
+
// the date is either the business date parameter of the query, or a date of its own
|
|
80
|
+
const dateValue = expression.parametersValues[3];
|
|
81
|
+
if (dateValue instanceof VariableExpression) {
|
|
82
|
+
assertTrue(
|
|
83
|
+
dateValue.name ===
|
|
84
|
+
queryBuilderState.watermarkState.businessDateVariable?.name,
|
|
85
|
+
`Can't process forDataDNSWatermark() expression: date must be the business date parameter or a date`,
|
|
86
|
+
);
|
|
87
|
+
dataDNSWatermark.setDate(dateValue);
|
|
88
|
+
} else {
|
|
89
|
+
const date = guaranteeType(
|
|
90
|
+
dateValue,
|
|
91
|
+
PrimitiveInstanceValue,
|
|
92
|
+
`Can't process forDataDNSWatermark() expression: date must be the business date parameter or a date`,
|
|
93
|
+
);
|
|
94
|
+
assertTrue(
|
|
95
|
+
(
|
|
96
|
+
[
|
|
97
|
+
PrimitiveType.STRICTDATE,
|
|
98
|
+
PrimitiveType.DATE,
|
|
99
|
+
PrimitiveType.DATETIME,
|
|
100
|
+
] as unknown[]
|
|
101
|
+
).includes(date.genericType.value.rawType),
|
|
102
|
+
`Can't process forDataDNSWatermark() expression: date must be a date`,
|
|
103
|
+
);
|
|
104
|
+
dataDNSWatermark.setDate(date);
|
|
105
|
+
}
|
|
106
|
+
const milestone = expression.parametersValues[4];
|
|
107
|
+
if (
|
|
108
|
+
!(milestone instanceof CollectionInstanceValue) ||
|
|
109
|
+
milestone.values.length > 0
|
|
110
|
+
) {
|
|
111
|
+
dataDNSWatermark.setMilestone(extractStringLiteral(milestone, 'milestone'));
|
|
112
|
+
}
|
|
113
|
+
queryBuilderState.watermarkState.setWatermark(dataDNSWatermark);
|
|
114
|
+
};
|
|
115
|
+
|
|
27
116
|
export const processWatermarkExpression = (
|
|
28
117
|
expression: SimpleFunctionExpression,
|
|
29
118
|
queryBuilderState: QueryBuilderState,
|
|
@@ -33,7 +122,7 @@ export const processWatermarkExpression = (
|
|
|
33
122
|
const precedingExpression = guaranteeType(
|
|
34
123
|
expression.parametersValues[0],
|
|
35
124
|
SimpleFunctionExpression,
|
|
36
|
-
`Can't process
|
|
125
|
+
`Can't process ${expression.functionName}() expression: only support ${expression.functionName}() immediately following an expression`,
|
|
37
126
|
);
|
|
38
127
|
assertTrue(
|
|
39
128
|
matchFunctionName(precedingExpression.functionName, [
|
|
@@ -41,7 +130,7 @@ export const processWatermarkExpression = (
|
|
|
41
130
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
|
42
131
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
|
43
132
|
]),
|
|
44
|
-
`Can't process
|
|
133
|
+
`Can't process ${expression.functionName}() expression: only support ${expression.functionName}() immediately following getAll()`,
|
|
45
134
|
);
|
|
46
135
|
|
|
47
136
|
QueryBuilderValueSpecificationProcessor.process(
|
|
@@ -50,6 +139,23 @@ export const processWatermarkExpression = (
|
|
|
50
139
|
queryBuilderState,
|
|
51
140
|
);
|
|
52
141
|
|
|
142
|
+
if (
|
|
143
|
+
matchFunctionName(
|
|
144
|
+
expression.functionName,
|
|
145
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.DATA_DNS_WATERMARK,
|
|
146
|
+
)
|
|
147
|
+
) {
|
|
148
|
+
processDataDNSWatermarkExpression(expression, queryBuilderState);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
53
152
|
const watermarkValue = expression.parametersValues[1];
|
|
54
|
-
queryBuilderState.watermarkState.
|
|
153
|
+
queryBuilderState.watermarkState.setWatermark(
|
|
154
|
+
new QueryBuilderStandardWatermark(
|
|
155
|
+
guaranteeNonNullable(
|
|
156
|
+
watermarkValue,
|
|
157
|
+
`Can't process forWatermark() expression: watermark value is missing`,
|
|
158
|
+
),
|
|
159
|
+
),
|
|
160
|
+
);
|
|
55
161
|
};
|
|
@@ -15,36 +15,116 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
+
CollectionInstanceValue,
|
|
19
|
+
GenericType,
|
|
20
|
+
GenericTypeExplicitReference,
|
|
21
|
+
Multiplicity,
|
|
22
|
+
PrimitiveInstanceValue,
|
|
23
|
+
PrimitiveType,
|
|
18
24
|
SimpleFunctionExpression,
|
|
25
|
+
VariableExpression,
|
|
19
26
|
extractElementNameFromPath,
|
|
20
27
|
type LambdaFunction,
|
|
28
|
+
type ValueSpecification,
|
|
21
29
|
} from '@finos/legend-graph';
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
import {
|
|
31
|
+
assertTrue,
|
|
32
|
+
guaranteeNonNullable,
|
|
33
|
+
UnsupportedOperationError,
|
|
34
|
+
} from '@finos/legend-shared';
|
|
35
|
+
import {
|
|
36
|
+
DATA_DNS_ENV_ENUMERATION_PATH,
|
|
37
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
|
38
|
+
} from '../../graph/QueryBuilderMetaModelConst.js';
|
|
39
|
+
import { buildEnumInstanceValue } from '../shared/ValueSpecificationEditorHelper.js';
|
|
40
|
+
import {
|
|
41
|
+
type QueryBuilderWatermarkState,
|
|
42
|
+
QueryBuilderDataDNSWatermark,
|
|
43
|
+
QueryBuilderStandardWatermark,
|
|
44
|
+
} from './QueryBuilderWatermarkState.js';
|
|
45
|
+
|
|
46
|
+
const buildStringValue = (value: string): PrimitiveInstanceValue => {
|
|
47
|
+
const instance = new PrimitiveInstanceValue(
|
|
48
|
+
GenericTypeExplicitReference.create(new GenericType(PrimitiveType.STRING)),
|
|
49
|
+
);
|
|
50
|
+
instance.values = [value];
|
|
51
|
+
return instance;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const buildDataDNSWatermarkExpression = (
|
|
55
|
+
watermarkState: QueryBuilderWatermarkState,
|
|
56
|
+
dataDNSWatermark: QueryBuilderDataDNSWatermark,
|
|
57
|
+
currentExpression: ValueSpecification,
|
|
58
|
+
): SimpleFunctionExpression => {
|
|
59
|
+
const expression = new SimpleFunctionExpression(
|
|
60
|
+
extractElementNameFromPath(
|
|
61
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.DATA_DNS_WATERMARK,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
const date = guaranteeNonNullable(
|
|
65
|
+
dataDNSWatermark.date,
|
|
66
|
+
`Can't build forDataDNSWatermark() expression: the date is missing`,
|
|
67
|
+
);
|
|
68
|
+
// the parser only accepts the business date parameter of the query as a parameter date
|
|
69
|
+
if (date instanceof VariableExpression) {
|
|
70
|
+
assertTrue(
|
|
71
|
+
date.name === watermarkState.businessDateVariable?.name,
|
|
72
|
+
`Can't build forDataDNSWatermark() expression: the date parameter '${date.name}' is not the business date of the query`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const milestone = dataDNSWatermark.milestone
|
|
76
|
+
? buildStringValue(dataDNSWatermark.milestone)
|
|
77
|
+
: new CollectionInstanceValue(Multiplicity.ZERO);
|
|
78
|
+
expression.parametersValues = [
|
|
79
|
+
currentExpression,
|
|
80
|
+
buildEnumInstanceValue(
|
|
81
|
+
watermarkState.queryBuilderState.graphManagerState.graph,
|
|
82
|
+
DATA_DNS_ENV_ENUMERATION_PATH,
|
|
83
|
+
dataDNSWatermark.env,
|
|
84
|
+
watermarkState.queryBuilderState.observerContext,
|
|
85
|
+
),
|
|
86
|
+
buildStringValue(dataDNSWatermark.registryUri),
|
|
87
|
+
date,
|
|
88
|
+
milestone,
|
|
89
|
+
];
|
|
90
|
+
return expression;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const buildStandardWatermarkExpression = (
|
|
94
|
+
watermark: QueryBuilderStandardWatermark,
|
|
95
|
+
currentExpression: ValueSpecification,
|
|
96
|
+
): SimpleFunctionExpression => {
|
|
97
|
+
const watermarkExpression = new SimpleFunctionExpression(
|
|
98
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK),
|
|
99
|
+
);
|
|
100
|
+
watermarkExpression.parametersValues = [currentExpression, watermark.value];
|
|
101
|
+
return watermarkExpression;
|
|
102
|
+
};
|
|
25
103
|
|
|
26
104
|
export const buildWatermarkExpression = (
|
|
27
105
|
watermarkState: QueryBuilderWatermarkState,
|
|
28
106
|
lambdaFunction: LambdaFunction,
|
|
29
107
|
): void => {
|
|
30
|
-
|
|
108
|
+
const watermark = watermarkState.watermark;
|
|
109
|
+
if (!watermark) {
|
|
31
110
|
return;
|
|
32
111
|
}
|
|
33
112
|
const currentExpression = guaranteeNonNullable(
|
|
34
113
|
lambdaFunction.expressionSequence[0],
|
|
35
114
|
);
|
|
36
|
-
|
|
37
|
-
// main filter expression
|
|
38
|
-
const watermarkExpression = new SimpleFunctionExpression(
|
|
39
|
-
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// param [0]
|
|
43
|
-
watermarkExpression.parametersValues.push(currentExpression);
|
|
44
|
-
|
|
45
|
-
// param [1]
|
|
46
|
-
watermarkExpression.parametersValues.push(watermarkState.value);
|
|
47
|
-
|
|
48
115
|
// replace watermark as main expression
|
|
49
|
-
|
|
116
|
+
if (watermark instanceof QueryBuilderDataDNSWatermark) {
|
|
117
|
+
lambdaFunction.expressionSequence[0] = buildDataDNSWatermarkExpression(
|
|
118
|
+
watermarkState,
|
|
119
|
+
watermark,
|
|
120
|
+
currentExpression,
|
|
121
|
+
);
|
|
122
|
+
} else if (watermark instanceof QueryBuilderStandardWatermark) {
|
|
123
|
+
lambdaFunction.expressionSequence[0] = buildStandardWatermarkExpression(
|
|
124
|
+
watermark,
|
|
125
|
+
currentExpression,
|
|
126
|
+
);
|
|
127
|
+
} else {
|
|
128
|
+
throw new UnsupportedOperationError(`Can't build watermark expression`);
|
|
129
|
+
}
|
|
50
130
|
};
|