@finos/legend-query-builder 4.10.0 → 4.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/lib/__lib__/QueryBuilderEvent.d.ts +2 -1
  2. package/lib/__lib__/QueryBuilderEvent.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderEvent.js +1 -0
  4. package/lib/__lib__/QueryBuilderEvent.js.map +1 -1
  5. package/lib/__lib__/QueryBuilderTesting.d.ts +1 -0
  6. package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
  7. package/lib/__lib__/QueryBuilderTesting.js +1 -0
  8. package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
  9. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  10. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +2 -1
  11. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  12. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +1 -1
  13. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
  14. package/lib/components/filter/QueryBuilderFilterPanel.d.ts +3 -2
  15. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  16. package/lib/components/filter/QueryBuilderFilterPanel.js +145 -8
  17. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  18. package/lib/graph/QueryBuilderMetaModelConst.d.ts +22 -1
  19. package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
  20. package/lib/graph/QueryBuilderMetaModelConst.js +24 -0
  21. package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
  22. package/lib/index.css +0 -16
  23. package/lib/index.d.ts +2 -1
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js +2 -1
  26. package/lib/index.js.map +1 -1
  27. package/lib/package.json +1 -1
  28. package/lib/stores/QueryBuilderPreviewDataHelper.d.ts.map +1 -1
  29. package/lib/stores/QueryBuilderPreviewDataHelper.js +2 -1
  30. package/lib/stores/QueryBuilderPreviewDataHelper.js.map +1 -1
  31. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  32. package/lib/stores/QueryBuilderState.js +2 -0
  33. package/lib/stores/QueryBuilderState.js.map +1 -1
  34. package/lib/stores/QueryBuilderTypeaheadHelper.d.ts.map +1 -1
  35. package/lib/stores/QueryBuilderTypeaheadHelper.js +1 -1
  36. package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -1
  37. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts +4 -1
  38. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts.map +1 -1
  39. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js +37 -3
  40. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js.map +1 -1
  41. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts +1 -4
  42. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts.map +1 -1
  43. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js +1 -5
  44. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js.map +1 -1
  45. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.d.ts +1 -1
  46. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.d.ts.map +1 -1
  47. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js +2 -2
  48. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js.map +1 -1
  49. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts +3 -2
  50. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts.map +1 -1
  51. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js +9 -0
  52. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js.map +1 -1
  53. package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.d.ts.map +1 -1
  54. package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js +2 -4
  55. package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js.map +1 -1
  56. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.d.ts +2 -1
  57. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.d.ts.map +1 -1
  58. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +1 -15
  59. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
  60. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +3 -44
  61. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  62. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
  63. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +13 -3
  64. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
  65. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
  66. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +3 -2
  67. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js.map +1 -1
  68. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts +2 -1
  69. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts.map +1 -1
  70. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +2 -1
  71. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js.map +1 -1
  72. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
  73. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +2 -2
  74. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
  75. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
  76. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +3 -10
  77. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
  78. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts +1 -1
  79. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts.map +1 -1
  80. package/lib/stores/filter/QueryBuilderFilterState.d.ts +7 -1
  81. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  82. package/lib/stores/filter/QueryBuilderFilterState.js +27 -0
  83. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  84. package/package.json +5 -5
  85. package/src/__lib__/QueryBuilderEvent.ts +1 -0
  86. package/src/__lib__/QueryBuilderTesting.ts +1 -0
  87. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +2 -4
  88. package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +1 -1
  89. package/src/components/filter/QueryBuilderFilterPanel.tsx +239 -21
  90. package/src/graph/QueryBuilderMetaModelConst.ts +25 -0
  91. package/src/index.ts +9 -2
  92. package/src/stores/QueryBuilderPreviewDataHelper.ts +2 -4
  93. package/src/stores/QueryBuilderState.ts +5 -0
  94. package/src/stores/QueryBuilderTypeaheadHelper.ts +2 -4
  95. package/src/stores/fetch-structure/tds/QueryBuilderTDSHelper.ts +58 -2
  96. package/src/stores/fetch-structure/tds/QueryResultSetModifierState.ts +1 -5
  97. package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.ts +5 -9
  98. package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.ts +16 -2
  99. package/src/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.ts +2 -4
  100. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.ts +1 -1
  101. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +1 -50
  102. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +22 -4
  103. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +4 -4
  104. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +1 -1
  105. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +5 -5
  106. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +5 -15
  107. package/src/stores/fetch-structure/tds/window/QueryBuilderWindowState.ts +1 -1
  108. package/src/stores/filter/QueryBuilderFilterState.ts +40 -1
package/src/index.ts CHANGED
@@ -29,7 +29,10 @@ export { QueryBuilderNavigationBlocker } from './components/QueryBuilderNavigati
29
29
  export { QueryBuilder } from './components/QueryBuilder.js';
30
30
  export { QUERY_BUILDER_COMPONENT_ELEMENT_ID } from './components/QueryBuilderComponentElement.js';
31
31
  export { QueryBuilderState } from './stores/QueryBuilderState.js';
32
-
32
+ export {
33
+ getTDSColumnDerivedProperyFromType,
34
+ buildTDSSortTypeExpression,
35
+ } from './stores/fetch-structure/tds/QueryBuilderTDSHelper.js';
33
36
  export { QueryBuilderPropertySearchState } from './stores/explorer/QueryBuilderPropertySearchState.js';
34
37
  export {
35
38
  QueryBuilderClassSelector,
@@ -43,7 +46,11 @@ export {
43
46
  type ServiceExecutionContext,
44
47
  ServiceQueryBuilderState,
45
48
  } from './stores/workflows/ServiceQueryBuilderState.js';
46
- export { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from './graph/QueryBuilderMetaModelConst.js';
49
+ export {
50
+ TDS_COLUMN_GETTER,
51
+ COLUMN_SORT_TYPE,
52
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS,
53
+ } from './graph/QueryBuilderMetaModelConst.js';
47
54
  export { getQueryBuilderGraphManagerExtension } from './graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.js';
48
55
  export type { ServiceExecutionAnalysisResult } from './graph-manager/action/analytics/ServiceExecutionAnalysis.js';
49
56
  export type { MappingRuntimeCompatibilityAnalysisResult } from './graph-manager/action/analytics/MappingRuntimeCompatibilityAnalysis.js';
@@ -29,12 +29,10 @@ import { QueryBuilderAggregateOperator_StdDev_Sample } from './fetch-structure/t
29
29
  import { QueryBuilderAggregateOperator_Sum } from './fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_Sum.js';
30
30
  import { QueryBuilderSimpleProjectionColumnState } from './fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js';
31
31
  import type { QueryBuilderState } from './QueryBuilderState.js';
32
- import {
33
- COLUMN_SORT_TYPE,
34
- SortColumnState,
35
- } from './fetch-structure/tds/QueryResultSetModifierState.js';
32
+ import { SortColumnState } from './fetch-structure/tds/QueryResultSetModifierState.js';
36
33
  import type { QueryBuilderAggregateOperator } from './fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js';
37
34
  import { QueryBuilderTDSState } from './fetch-structure/tds/QueryBuilderTDSState.js';
35
+ import { COLUMN_SORT_TYPE } from '../graph/QueryBuilderMetaModelConst.js';
38
36
 
39
37
  const PREVIEW_DATA_TAKE_LIMIT = 10;
40
38
  const PREVIEW_DATA_NON_NUMERIC_VALUE_COLUMN_NAME = 'Value';
@@ -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;
@@ -555,6 +556,10 @@ export abstract class QueryBuilderState implements CommandRegistrar {
555
556
  this.fetchStructureState.initializeWithQuery();
556
557
  } catch (error) {
557
558
  assertErrorThrown(error);
559
+ this.applicationStore.logService.error(
560
+ LogEvent.create(QUERY_BUILDER_EVENT.UNSUPPORTED_QUERY_LAUNCH),
561
+ error,
562
+ );
558
563
  this.resetQueryResult({ preserveResult: options?.preserveResult });
559
564
  this.resetQueryContent();
560
565
  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 { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../graph/QueryBuilderMetaModelConst.js';
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(aggregateColumnState: QueryBuilderAggregateColumnState): Type {
86
- return guaranteeNonNullable(
87
- aggregateColumnState.projectionColumnState.getColumnType(),
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 type { QueryBuilderProjectionColumnState } from '../projection/QueryBuilderProjectionColumnState.js';
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
- const graph =
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 { getTDSColumnState } from '../QueryBuilderTDSHelper.js';
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 { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graph/QueryBuilderMetaModelConst.js';
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
- type PostFilterConditionState,
36
+ QUERY_BUILDER_PURE_PATH,
36
37
  type TDS_COLUMN_GETTER,
37
- getTDSColumnDerivedProperyFromType,
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 { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graph/QueryBuilderMetaModelConst.js';
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,
@@ -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
- const sortColumnFunction = new SimpleFunctionExpression(
57
- extractElementNameFromPath(
58
- sortColumnState.sortType === COLUMN_SORT_TYPE.ASC
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
 
@@ -466,6 +466,7 @@ export class QueryBuilderFilterState
466
466
  addNodeFromNode: action,
467
467
  replaceBlankNodeWithNode: action,
468
468
  addGroupConditionNodeFromNode: action,
469
+ newGroupConditionFromNode: action,
469
470
  newGroupWithConditionFromNode: action,
470
471
  removeNodeAndPruneBranch: action,
471
472
  pruneTree: action,
@@ -514,7 +515,7 @@ export class QueryBuilderFilterState
514
515
  return rootId ? this.getNode(rootId) : undefined;
515
516
  }
516
517
 
517
- private getParentNode(
518
+ getParentNode(
518
519
  node: QueryBuilderFilterTreeNodeData,
519
520
  ): QueryBuilderFilterTreeOperationNodeData | undefined {
520
521
  return node.parentId
@@ -635,6 +636,44 @@ export class QueryBuilderFilterState
635
636
  this.addNodeFromNode(newGroupNode, fromNode);
636
637
  }
637
638
 
639
+ /**
640
+ *
641
+ * Function to create group condition from node where either of the
642
+ * child nodes of group condition is `exists` node
643
+ */
644
+ newGroupConditionFromNode(
645
+ fromNode:
646
+ | QueryBuilderFilterTreeConditionNodeData
647
+ | QueryBuilderFilterTreeExistsNodeData,
648
+ node?:
649
+ | QueryBuilderFilterTreeConditionNodeData
650
+ | QueryBuilderFilterTreeExistsNodeData
651
+ | undefined,
652
+ operation?: QUERY_BUILDER_GROUP_OPERATION | undefined,
653
+ ): QueryBuilderFilterTreeGroupNodeData {
654
+ const fromNodeParent = this.getParentNode(fromNode);
655
+ const newGroupNode = new QueryBuilderFilterTreeGroupNodeData(
656
+ undefined,
657
+ operation ?? QUERY_BUILDER_GROUP_OPERATION.AND,
658
+ );
659
+ this.nodes.set(newGroupNode.id, newGroupNode);
660
+ fromNodeParent?.removeChildNode(fromNode);
661
+ newGroupNode.addChildNode(fromNode);
662
+ if (node) {
663
+ this.nodes.set(node.id, node);
664
+ newGroupNode.addChildNode(node);
665
+ }
666
+ newGroupNode.lambdaParameterName =
667
+ fromNodeParent?.lambdaParameterName ?? this.lambdaParameterName;
668
+ if (fromNodeParent) {
669
+ fromNodeParent.addChildNode(newGroupNode);
670
+ } else {
671
+ deleteEntry(this.rootIds, fromNode.id);
672
+ this.addRootNode(newGroupNode);
673
+ }
674
+ return newGroupNode;
675
+ }
676
+
638
677
  newGroupWithConditionFromNode(
639
678
  node: QueryBuilderFilterTreeNodeData | undefined,
640
679
  fromNode: QueryBuilderFilterTreeNodeData | undefined,