@finos/legend-query-builder 4.18.0 → 4.18.2

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.
Files changed (135) hide show
  1. package/lib/__test__.d.ts +1 -0
  2. package/lib/__test__.d.ts.map +1 -1
  3. package/lib/__test__.js +1 -0
  4. package/lib/__test__.js.map +1 -1
  5. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  6. package/lib/components/QueryBuilderSideBar.js +10 -2
  7. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  8. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +5 -0
  9. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  10. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +28 -2
  11. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  12. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.d.ts.map +1 -1
  13. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +8 -2
  14. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
  15. package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.d.ts.map +1 -1
  16. package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.js +15 -3
  17. package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.js.map +1 -1
  18. package/lib/components/sql-playground/SQLPlaygroundPanel.d.ts.map +1 -1
  19. package/lib/components/sql-playground/SQLPlaygroundPanel.js +9 -5
  20. package/lib/components/sql-playground/SQLPlaygroundPanel.js.map +1 -1
  21. package/lib/components/workflows/AccessorQueryBuilder.js +1 -1
  22. package/lib/components/workflows/AccessorQueryBuilder.js.map +1 -1
  23. package/lib/components/workflows/DataProductQueryBuilder.d.ts.map +1 -1
  24. package/lib/components/workflows/DataProductQueryBuilder.js +13 -12
  25. package/lib/components/workflows/DataProductQueryBuilder.js.map +1 -1
  26. package/lib/data-access-overview.css +1 -1
  27. package/lib/graph/QueryBuilderMetaModelConst.d.ts +2 -0
  28. package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
  29. package/lib/graph/QueryBuilderMetaModelConst.js +2 -0
  30. package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
  31. package/lib/index.css +2 -2
  32. package/lib/index.css.map +1 -1
  33. package/lib/index.d.ts +1 -1
  34. package/lib/index.d.ts.map +1 -1
  35. package/lib/index.js +1 -1
  36. package/lib/index.js.map +1 -1
  37. package/lib/package.json +1 -1
  38. package/lib/stores/QueryBuilderStateHashUtils.d.ts +1 -0
  39. package/lib/stores/QueryBuilderStateHashUtils.d.ts.map +1 -1
  40. package/lib/stores/QueryBuilderStateHashUtils.js +1 -0
  41. package/lib/stores/QueryBuilderStateHashUtils.js.map +1 -1
  42. package/lib/stores/QueryBuilderTypeaheadHelper.js +4 -4
  43. package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -1
  44. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts +1 -1
  45. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts.map +1 -1
  46. package/lib/stores/QueryBuilderValueSpecificationHelper.js +2 -2
  47. package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
  48. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.d.ts +374 -0
  49. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.d.ts.map +1 -0
  50. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.js +625 -0
  51. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.js.map +1 -0
  52. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  53. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +3 -2
  54. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  55. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderRelationAggregationValueSpecBuilder.js +2 -2
  56. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderRelationAggregationValueSpecBuilder.js.map +1 -1
  57. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.js +1 -1
  58. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.js.map +1 -1
  59. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
  60. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +8 -6
  61. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
  62. package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuilder.js +2 -2
  63. package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuilder.js.map +1 -1
  64. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowGroupByOperatorLoader.d.ts.map +1 -1
  65. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowGroupByOperatorLoader.js +2 -0
  66. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowGroupByOperatorLoader.js.map +1 -1
  67. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowStateBuilder.d.ts.map +1 -1
  68. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowStateBuilder.js +40 -14
  69. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowStateBuilder.js.map +1 -1
  70. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowValueSpecificationBuilder.d.ts.map +1 -1
  71. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowValueSpecificationBuilder.js +72 -30
  72. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowValueSpecificationBuilder.js.map +1 -1
  73. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator.d.ts +1 -1
  74. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator.d.ts.map +1 -1
  75. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Average.js +1 -1
  76. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Average.js.map +1 -1
  77. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Count.js +1 -1
  78. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Count.js.map +1 -1
  79. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Max.js +1 -1
  80. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Max.js.map +1 -1
  81. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Min.js +1 -1
  82. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Min.js.map +1 -1
  83. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_PercentRank.d.ts +25 -0
  84. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_PercentRank.d.ts.map +1 -0
  85. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_PercentRank.js +54 -0
  86. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_PercentRank.js.map +1 -0
  87. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Sum.js +1 -1
  88. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Sum.js.map +1 -1
  89. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowRankOperator_RowNumber.js +1 -1
  90. package/lib/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowRankOperator_RowNumber.js.map +1 -1
  91. package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.js +3 -3
  92. package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.js.map +1 -1
  93. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.d.ts +1 -0
  94. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.d.ts.map +1 -1
  95. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.js +4 -0
  96. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.js.map +1 -1
  97. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.d.ts +38 -9
  98. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.d.ts.map +1 -1
  99. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.js +263 -45
  100. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.js.map +1 -1
  101. package/package.json +10 -10
  102. package/src/__test__.ts +1 -0
  103. package/src/components/QueryBuilderSideBar.tsx +10 -7
  104. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +73 -1
  105. package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +10 -4
  106. package/src/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.tsx +33 -3
  107. package/src/components/sql-playground/SQLPlaygroundPanel.tsx +10 -5
  108. package/src/components/workflows/AccessorQueryBuilder.tsx +2 -2
  109. package/src/components/workflows/DataProductQueryBuilder.tsx +40 -62
  110. package/src/graph/QueryBuilderMetaModelConst.ts +2 -0
  111. package/src/index.ts +3 -0
  112. package/src/stores/QueryBuilderStateHashUtils.ts +1 -0
  113. package/src/stores/QueryBuilderTypeaheadHelper.ts +4 -4
  114. package/src/stores/QueryBuilderValueSpecificationHelper.ts +5 -3
  115. package/src/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.ts +630 -0
  116. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +3 -2
  117. package/src/stores/fetch-structure/tds/aggregation/QueryBuilderRelationAggregationValueSpecBuilder.ts +2 -2
  118. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.ts +1 -1
  119. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +8 -6
  120. package/src/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuilder.ts +2 -2
  121. package/src/stores/fetch-structure/tds/window/QueryBuilderWindowGroupByOperatorLoader.ts +2 -0
  122. package/src/stores/fetch-structure/tds/window/QueryBuilderWindowStateBuilder.ts +85 -25
  123. package/src/stores/fetch-structure/tds/window/QueryBuilderWindowValueSpecificationBuilder.ts +141 -38
  124. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator.ts +1 -1
  125. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Average.ts +1 -1
  126. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Count.ts +1 -1
  127. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Max.ts +1 -1
  128. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Min.ts +1 -1
  129. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_PercentRank.ts +57 -0
  130. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Sum.ts +1 -1
  131. package/src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowRankOperator_RowNumber.ts +1 -1
  132. package/src/stores/filter/QueryBuilderFilterValueSpecificationBuilder.ts +3 -3
  133. package/src/stores/workflows/accessor/AccessorQueryBuilderState.ts +5 -0
  134. package/src/stores/workflows/dataProduct/DataProductQueryBuilderState.ts +424 -69
  135. package/tsconfig.json +2 -0
@@ -32,6 +32,7 @@ import {
32
32
  SimpleFunctionExpression,
33
33
  InstanceValue,
34
34
  Multiplicity,
35
+ type MappingModelCoverageAnalysisResult,
35
36
  extractElementNameFromPath,
36
37
  SUPPORTED_FUNCTIONS,
37
38
  PackageableElementExplicitReference,
@@ -40,8 +41,21 @@ import {
40
41
  type QueryExecutionContext,
41
42
  QueryDataProductNativeExecutionContext,
42
43
  QueryDataProductModelAccessExecutionContext,
44
+ QueryDataProductLakehouseExecutionContext,
45
+ LakehouseAccessPoint,
43
46
  type RawLambda,
44
47
  buildRawLambdaFromLambdaFunction,
48
+ type Accessor,
49
+ type RelationTypeMetadata,
50
+ DataProductAccessor,
51
+ RelationType,
52
+ RelationColumn,
53
+ GenericType,
54
+ GenericTypeExplicitReference,
55
+ findLakehouseAccessPointGroup,
56
+ type PureModel,
57
+ DataProductAccessType,
58
+ LegendSDLC,
45
59
  } from '@finos/legend-graph';
46
60
  import { QueryBuilderState } from '../../QueryBuilderState.js';
47
61
 
@@ -63,11 +77,41 @@ import { action, computed, flow, makeObservable, observable } from 'mobx';
63
77
  import {
64
78
  DepotEntityWithOrigin,
65
79
  type QueryableSourceInfo,
80
+ type ProjectGAVCoordinates,
66
81
  } from '@finos/legend-storage';
67
82
  import { compareLabelFn } from '@finos/legend-art';
68
83
  import { QueryBuilderEmbeddedFromExecutionContextState } from '../../QueryBuilderExecutionContextState.js';
69
84
  import { buildLambdaFunction } from '../../QueryBuilderValueSpecificationBuilder.js';
70
85
 
86
+ export const buildDataProductAccessor = (
87
+ relationMetadata: RelationTypeMetadata,
88
+ dataProduct: DataProduct,
89
+ accessPoint: LakehouseAccessPoint,
90
+ graph: PureModel,
91
+ ): DataProductAccessor => {
92
+ const relationType = new RelationType(accessPoint.title ?? accessPoint.id);
93
+ relationType.columns = relationMetadata.columns.map(
94
+ (col) =>
95
+ new RelationColumn(
96
+ col.name,
97
+ GenericTypeExplicitReference.create(
98
+ new GenericType(graph.getType(col.type)),
99
+ ),
100
+ ),
101
+ );
102
+ const groupResult = findLakehouseAccessPointGroup(
103
+ dataProduct,
104
+ accessPoint.id,
105
+ );
106
+ return new DataProductAccessor(
107
+ dataProduct.path,
108
+ groupResult?.group.id,
109
+ accessPoint.id,
110
+ relationType,
111
+ dataProduct,
112
+ );
113
+ };
114
+
71
115
  export type DataProductOption = {
72
116
  label: string;
73
117
  value: DepotEntityWithOrigin;
@@ -104,6 +148,15 @@ export const buildModelAccessPointGroupOption = (
104
148
  value,
105
149
  });
106
150
 
151
+ export type ExecutionIdOption = {
152
+ label: string;
153
+ tag: string;
154
+ value:
155
+ | NativeModelExecutionContext
156
+ | ModelAccessPointGroup
157
+ | LakehouseAccessPoint;
158
+ };
159
+
107
160
  export abstract class DataProductExecutionState<T> {
108
161
  readonly queryBuilderState: DataProductQueryBuilderState;
109
162
  exectionValue: T;
@@ -118,10 +171,14 @@ export abstract class DataProductExecutionState<T> {
118
171
 
119
172
  abstract get label(): string;
120
173
 
121
- abstract get mapping(): Mapping;
174
+ abstract get mapping(): Mapping | undefined;
122
175
 
123
176
  abstract get featuredElements(): DataProductElementScope[] | undefined;
124
177
 
178
+ get showRuntimeOptions(): boolean {
179
+ return false;
180
+ }
181
+
125
182
  get selectedOption(): { label: string; value: T } {
126
183
  return {
127
184
  label: this.label,
@@ -196,7 +253,7 @@ export class ModelAccessPointDataProductExecutionState extends DataProductExecut
196
253
  return this.exectionValue.featuredElements;
197
254
  }
198
255
 
199
- get showRuntimeOptions(): boolean {
256
+ override get showRuntimeOptions(): boolean {
200
257
  return this.compatibleRuntimes.length > 1;
201
258
  }
202
259
 
@@ -207,20 +264,61 @@ export class ModelAccessPointDataProductExecutionState extends DataProductExecut
207
264
  }
208
265
  }
209
266
 
267
+ export class LakehouseDataProductExecutionState extends DataProductExecutionState<LakehouseAccessPoint> {
268
+ selectedRuntime: PackageableRuntime | undefined;
269
+ adhocRuntime = false;
270
+ constructor(
271
+ executionState: LakehouseAccessPoint,
272
+ queryBuilderState: DataProductQueryBuilderState,
273
+ ) {
274
+ super(executionState, queryBuilderState);
275
+ makeObservable(this, {});
276
+ this.selectedRuntime = this.compatibleRuntimes[0];
277
+ }
278
+
279
+ changeSelectedRuntime(val: PackageableRuntime): void {
280
+ this.selectedRuntime = val;
281
+ this.queryBuilderState.changeRuntime(val);
282
+ }
283
+
284
+ override get label(): string {
285
+ return this.exectionValue.title ?? this.exectionValue.id;
286
+ }
287
+
288
+ get mapping(): Mapping | undefined {
289
+ return undefined;
290
+ }
291
+
292
+ get featuredElements(): DataProductElementScope[] | undefined {
293
+ return undefined;
294
+ }
295
+
296
+ get compatibleRuntimes(): PackageableRuntime[] {
297
+ return this.queryBuilderState.graphManagerState.usableRuntimes.filter(
298
+ (runtime) => runtime.runtimeValue instanceof LakehouseRuntime,
299
+ );
300
+ }
301
+
302
+ override get showRuntimeOptions(): boolean {
303
+ return this.compatibleRuntimes.length > 1;
304
+ }
305
+ }
306
+
210
307
  export class DataProductQueryBuilderState extends QueryBuilderState {
211
308
  readonly onClassChange?: ((val: Class) => void) | undefined;
212
309
  readonly onDataProductChange?: (val: DepotEntityWithOrigin) => Promise<void>;
213
- readonly onExecutionContextChange?:
214
- | ((val: NativeModelExecutionContext) => void)
215
- | undefined;
216
310
 
217
311
  loadDataProductModelState = ActionState.create();
218
312
  dataProduct: DataProduct;
219
313
  dataProductArtifact: V1_DataProductArtifact | undefined;
220
314
  executionState: DataProductExecutionState<
221
- NativeModelExecutionContext | ModelAccessPointGroup
315
+ NativeModelExecutionContext | ModelAccessPointGroup | LakehouseAccessPoint
222
316
  >;
223
317
  entities: DepotEntityWithOrigin[] | undefined;
318
+ mappingToMappingCoverageResult?: Map<
319
+ string,
320
+ MappingModelCoverageAnalysisResult
321
+ >;
224
322
 
225
323
  prioritizeEntityFunc?: ((val: DepotEntityWithOrigin) => boolean) | undefined;
226
324
 
@@ -234,12 +332,12 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
234
332
  dataProduct: DataProduct,
235
333
  artifact: V1_DataProductArtifact | undefined,
236
334
  actionConfig: QueryBuilderActionConfig,
237
- executionState: NativeModelExecutionContext | ModelAccessPointGroup,
335
+ executionState:
336
+ | NativeModelExecutionContext
337
+ | ModelAccessPointGroup
338
+ | LakehouseAccessPoint,
238
339
  prioritizeEntityFunc: ((val: DepotEntityWithOrigin) => boolean) | undefined,
239
340
  onDataProductChange: (val: DepotEntityWithOrigin) => Promise<void>,
240
- onExecutionContextChange?:
241
- | ((val: NativeModelExecutionContext) => void)
242
- | undefined,
243
341
  onClassChange?: ((val: Class) => void) | undefined,
244
342
  config?: QueryBuilderConfig | undefined,
245
343
  sourceInfo?: QueryableSourceInfo | undefined,
@@ -255,8 +353,17 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
255
353
  isProductLinkable: computed,
256
354
  isNativeMode: computed,
257
355
  isModelAccessPointGroupMode: computed,
356
+ isLakehouseMode: computed,
258
357
  showExecutionContextOptions: computed,
259
358
  showModelAccessPointGroupSelector: computed,
359
+ showExecutionIdSelector: computed,
360
+ executionIdOptions: computed,
361
+ selectedExecutionIdOption: computed,
362
+ hasNativeModelAccess: computed,
363
+ hasBothAccessModes: computed,
364
+ showContextSelector: computed,
365
+ allContextOptions: computed,
366
+ selectedContextOption: computed,
260
367
  selectedExecOption: computed,
261
368
  selectedModelAccessPointGroupOption: computed,
262
369
  usableClasses: computed,
@@ -277,11 +384,36 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
277
384
  this.executionState =
278
385
  executionState instanceof NativeModelExecutionContext
279
386
  ? new NativeModelDataProductExecutionState(executionState, this)
280
- : new ModelAccessPointDataProductExecutionState(executionState, this);
387
+ : executionState instanceof LakehouseAccessPoint
388
+ ? new LakehouseDataProductExecutionState(executionState, this)
389
+ : new ModelAccessPointDataProductExecutionState(executionState, this);
281
390
  this.prioritizeEntityFunc = prioritizeEntityFunc;
282
391
  this.onDataProductChange = onDataProductChange;
283
- this.onExecutionContextChange = onExecutionContextChange;
284
392
  this.onClassChange = onClassChange;
393
+ // force from.
394
+ this.executionContextState =
395
+ new QueryBuilderEmbeddedFromExecutionContextState(this);
396
+ }
397
+
398
+ async prepareAccessForExecution(): Promise<void> {
399
+ if (this.executionState instanceof NativeModelDataProductExecutionState) {
400
+ const runtime = this.executionState.exectionValue.runtime;
401
+ if (runtime) {
402
+ this.changeRuntime(new RuntimePointer(runtime));
403
+ }
404
+ } else if (
405
+ this.executionState instanceof
406
+ ModelAccessPointDataProductExecutionState &&
407
+ this.executionState.selectedRuntime
408
+ ) {
409
+ this.changeRuntime(
410
+ new RuntimePointer(
411
+ PackageableElementExplicitReference.create(
412
+ this.executionState.selectedRuntime,
413
+ ),
414
+ ),
415
+ );
416
+ }
285
417
  }
286
418
 
287
419
  get isProductLinkable(): boolean {
@@ -298,6 +430,10 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
298
430
  );
299
431
  }
300
432
 
433
+ get isLakehouseMode(): boolean {
434
+ return this.executionState instanceof LakehouseDataProductExecutionState;
435
+ }
436
+
301
437
  get showExecutionContextOptions(): boolean {
302
438
  return this.isNativeMode && this.execOptions.length > 1;
303
439
  }
@@ -308,6 +444,105 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
308
444
  this.modelAccessPointGroupOptions.length > 1
309
445
  );
310
446
  }
447
+ get hasNativeModelAccess(): boolean {
448
+ return this.dataProduct.nativeModelAccess !== undefined;
449
+ }
450
+
451
+ get hasBothAccessModes(): boolean {
452
+ return this.hasModelAccessPointGroups && this.hasNativeModelAccess;
453
+ }
454
+
455
+ // showContextSelector / allContextOptions / selectedContextOption are aliases
456
+ // over the upstream ExecutionIdOption API so existing UI code keeps working.
457
+ get showContextSelector(): boolean {
458
+ return this.showExecutionIdSelector;
459
+ }
460
+
461
+ get allContextOptions(): ExecutionIdOption[] {
462
+ return this.executionIdOptions;
463
+ }
464
+
465
+ get selectedContextOption(): ExecutionIdOption | undefined {
466
+ return this.selectedExecutionIdOption;
467
+ }
468
+
469
+ get executionIdOptions(): ExecutionIdOption[] {
470
+ const nativeOptions: ExecutionIdOption[] = (
471
+ this.dataProduct.nativeModelAccess?.nativeModelExecutionContexts ?? []
472
+ ).map((ctx) => ({
473
+ label: ctx.key,
474
+ tag: 'NATIVE',
475
+ value: ctx,
476
+ }));
477
+ const modelOptions: ExecutionIdOption[] = this.modelAccessPointGroups.map(
478
+ (group) => ({
479
+ label: group.title ?? group.id,
480
+ tag: 'MODEL',
481
+ value: group,
482
+ }),
483
+ );
484
+ const lakehouseOptions: ExecutionIdOption[] =
485
+ this.dataProduct.accessPointGroups
486
+ .flatMap((group) => group.accessPoints)
487
+ .filter(filterByType(LakehouseAccessPoint))
488
+ .map((ap) => ({
489
+ label: ap.title ?? ap.id,
490
+ tag: 'LAKEHOUSE',
491
+ value: ap,
492
+ }));
493
+ return [...modelOptions, ...lakehouseOptions, ...nativeOptions].sort(
494
+ compareLabelFn,
495
+ );
496
+ }
497
+
498
+ get selectedExecutionIdOption(): ExecutionIdOption | undefined {
499
+ const state = this.executionState;
500
+ if (state instanceof NativeModelDataProductExecutionState) {
501
+ return {
502
+ label: state.exectionValue.key,
503
+ tag: 'NATIVE',
504
+ value: state.exectionValue,
505
+ };
506
+ } else if (state instanceof ModelAccessPointDataProductExecutionState) {
507
+ return {
508
+ label: state.exectionValue.title ?? state.exectionValue.id,
509
+ tag: 'MODEL',
510
+ value: state.exectionValue,
511
+ };
512
+ } else if (state instanceof LakehouseDataProductExecutionState) {
513
+ return {
514
+ label: state.exectionValue.title ?? state.exectionValue.id,
515
+ tag: 'LAKEHOUSE',
516
+ value: state.exectionValue,
517
+ };
518
+ }
519
+ return undefined;
520
+ }
521
+
522
+ get showExecutionIdSelector(): boolean {
523
+ return this.executionIdOptions.length > 1;
524
+ }
525
+
526
+ async changeExecutionId(option: ExecutionIdOption): Promise<void> {
527
+ const val = option.value;
528
+ if (val === this.executionState.exectionValue) {
529
+ return;
530
+ }
531
+ const switchingToModel = val instanceof ModelAccessPointGroup;
532
+ const switchingToNative = val instanceof NativeModelExecutionContext;
533
+ const wasModeSwitch =
534
+ (switchingToModel && this.isNativeMode) ||
535
+ (switchingToNative && this.isModelAccessPointGroupMode);
536
+
537
+ if (wasModeSwitch) {
538
+ this.changeHistoryState.querySnapshotBuffer = [];
539
+ this.changeHistoryState.pointer = -1;
540
+ this.changeHistoryState.setCurrentQuery(undefined);
541
+ }
542
+
543
+ await this.changeExecutionState(val);
544
+ await this.propagateExecutionContextChange();
545
+ }
311
546
 
312
547
  get selectedExecOption():
313
548
  | { label: string; value: NativeModelExecutionContext }
@@ -317,6 +552,13 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
317
552
  : undefined;
318
553
  }
319
554
 
555
+ override get requiresMappingForExecution(): boolean {
556
+ if (this.executionState instanceof LakehouseDataProductExecutionState) {
557
+ return false;
558
+ }
559
+ return true;
560
+ }
561
+
320
562
  get selectedModelAccessPointGroupOption():
321
563
  | ModelAccessPointGroupOption
322
564
  | undefined {
@@ -338,29 +580,6 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
338
580
  : [];
339
581
  }
340
582
 
341
- changeNativeExecutionContext(val: NativeModelExecutionContext): void {
342
- if (this.isNativeMode && val === this.executionState.exectionValue) {
343
- return;
344
- }
345
- this.setExecutionState(val);
346
- this.propagateExecutionContextChange()
347
- .then(() => this.onExecutionContextChange?.(val))
348
- .catch(this.applicationStore.alertUnhandledError);
349
- }
350
-
351
- changeModelAccessPointGroupValue(val: ModelAccessPointGroup): void {
352
- if (
353
- this.isModelAccessPointGroupMode &&
354
- val === this.executionState.exectionValue
355
- ) {
356
- return;
357
- }
358
- this.setExecutionState(val);
359
- this.propagateExecutionContextChange().catch(
360
- this.applicationStore.alertUnhandledError,
361
- );
362
- }
363
-
364
583
  override buildQueryForPersistence(): RawLambda {
365
584
  if (!this.isQuerySupported) {
366
585
  return this.buildQuery();
@@ -390,6 +609,13 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
390
609
  execContext.dataProductPath = this.dataProduct.path;
391
610
  execContext.accessPointGroupId = this.executionState.exectionValue.id;
392
611
  return execContext;
612
+ } else if (
613
+ this.executionState instanceof LakehouseDataProductExecutionState
614
+ ) {
615
+ const execContext = new QueryDataProductLakehouseExecutionContext();
616
+ execContext.dataProductPath = this.dataProduct.path;
617
+ execContext.accessPointId = this.executionState.exectionValue.id;
618
+ return execContext;
393
619
  }
394
620
  return super.getQueryExecutionContext();
395
621
  }
@@ -403,7 +629,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
403
629
  val.path,
404
630
  );
405
631
  if (dataProduct) {
406
- this.initWithDataProduct(dataProduct);
632
+ this.initWithDataProduct(dataProduct, undefined, undefined);
407
633
  this.loadDataProductModelState.pass();
408
634
  } else if (this.onDataProductChange) {
409
635
  // data product not in current graph — trigger full rebuild
@@ -430,17 +656,21 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
430
656
 
431
657
  initWithDataProduct(
432
658
  dataProduct: DataProduct,
433
- preResolvedState?: NativeModelExecutionContext | ModelAccessPointGroup,
659
+ accessor: Accessor | undefined,
660
+ preResolvedState?:
661
+ | NativeModelExecutionContext
662
+ | ModelAccessPointGroup
663
+ | LakehouseAccessPoint,
434
664
  ): void {
435
665
  try {
436
666
  const execValue =
437
667
  preResolvedState ?? resolveDataProductExecutionState(dataProduct);
438
668
  this.dataProduct = dataProduct;
439
- this.executionState =
440
- execValue instanceof NativeModelExecutionContext
441
- ? new NativeModelDataProductExecutionState(execValue, this)
442
- : new ModelAccessPointDataProductExecutionState(execValue, this);
443
- this.changeMapping(this.executionState.mapping);
669
+ this.setExecutionState(execValue);
670
+ const mapping = this.executionState.mapping;
671
+ if (mapping) {
672
+ this.changeMapping(mapping);
673
+ }
444
674
  if (this.executionState instanceof NativeModelDataProductExecutionState) {
445
675
  const runtime = guaranteeNonNullable(
446
676
  this.executionState.exectionValue.runtime,
@@ -453,19 +683,44 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
453
683
  this.executionState.selectedRuntime instanceof PackageableRuntime
454
684
  ) {
455
685
  this.changeRuntime(this.executionState.selectedRuntime);
686
+ } else if (
687
+ this.executionState instanceof LakehouseDataProductExecutionState &&
688
+ accessor &&
689
+ this.executionState.selectedRuntime instanceof PackageableRuntime
690
+ ) {
691
+ this.setSourceElement(accessor);
692
+ this.changeRuntime(
693
+ new RuntimePointer(
694
+ PackageableElementExplicitReference.create(
695
+ this.executionState.selectedRuntime,
696
+ ),
697
+ ),
698
+ );
456
699
  }
457
- const compatibleClasses = resolveUsableDataProductClasses(
458
- this.activeFeaturedElements,
459
- this.executionState.mapping,
460
- this.graphManagerState,
461
- undefined,
462
- );
463
- // if there is no chosen class or the chosen one is not compatible
464
- // with the mapping then pick a compatible class if possible
465
- if (!this.sourceClass || !compatibleClasses.includes(this.sourceClass)) {
466
- const possibleNewClass = compatibleClasses[0];
467
- if (possibleNewClass) {
468
- this.changeSourceElement(possibleNewClass);
700
+ if (mapping) {
701
+ const coverageResult = this.mappingToMappingCoverageResult?.get(
702
+ mapping.path,
703
+ );
704
+ if (coverageResult) {
705
+ this.explorerState.mappingModelCoverageAnalysisResult =
706
+ coverageResult;
707
+ }
708
+ const compatibleClasses = resolveUsableDataProductClasses(
709
+ this.activeFeaturedElements,
710
+ mapping,
711
+ this.graphManagerState,
712
+ coverageResult,
713
+ );
714
+ // if there is no chosen class or the chosen one is not compatible
715
+ // with the mapping then pick a compatible class if possible
716
+ if (
717
+ !this.sourceClass ||
718
+ !compatibleClasses.includes(this.sourceClass)
719
+ ) {
720
+ const possibleNewClass = compatibleClasses[0];
721
+ if (possibleNewClass) {
722
+ this.changeSourceElement(possibleNewClass);
723
+ }
469
724
  }
470
725
  }
471
726
  } catch (error) {
@@ -489,12 +744,40 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
489
744
  }
490
745
 
491
746
  setExecutionState(
492
- val: NativeModelExecutionContext | ModelAccessPointGroup,
747
+ val:
748
+ | NativeModelExecutionContext
749
+ | ModelAccessPointGroup
750
+ | LakehouseAccessPoint,
493
751
  ): void {
494
752
  this.executionState =
495
753
  val instanceof NativeModelExecutionContext
496
754
  ? new NativeModelDataProductExecutionState(val, this)
497
- : new ModelAccessPointDataProductExecutionState(val, this);
755
+ : val instanceof LakehouseAccessPoint
756
+ ? new LakehouseDataProductExecutionState(val, this)
757
+ : new ModelAccessPointDataProductExecutionState(val, this);
758
+ }
759
+
760
+ async changeExecutionState(
761
+ val:
762
+ | NativeModelExecutionContext
763
+ | ModelAccessPointGroup
764
+ | LakehouseAccessPoint,
765
+ ): Promise<void> {
766
+ this.setExecutionState(val);
767
+ if (val instanceof LakehouseAccessPoint) {
768
+ const relationMetadata =
769
+ await this.graphManagerState.graphManager.getLambdaRelationType(
770
+ val.func,
771
+ this.graphManagerState.graph,
772
+ );
773
+ const accessor = buildDataProductAccessor(
774
+ relationMetadata,
775
+ this.dataProduct,
776
+ val,
777
+ this.graphManagerState.graph,
778
+ );
779
+ this.setSourceElement(accessor);
780
+ }
498
781
  }
499
782
 
500
783
  get modelAccessPointGroups(): ModelAccessPointGroup[] {
@@ -613,7 +896,11 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
613
896
  // contains model access point group
614
897
  this.dataProduct.accessPointGroups.filter(
615
898
  filterByType(ModelAccessPointGroup),
616
- ).length > 0
899
+ ).length > 0 ||
900
+ // contains lakehouse access point
901
+ this.dataProduct.accessPointGroups.some((group) =>
902
+ group.accessPoints.some((ap) => ap instanceof LakehouseAccessPoint),
903
+ )
617
904
  );
618
905
  }
619
906
 
@@ -631,19 +918,87 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
631
918
  ): Promise<void> {
632
919
  const currentMapping = this.executionContextState.mapping;
633
920
  const newMapping = this.activeMapping;
634
- if (newMapping && newMapping !== currentMapping) {
635
- this.changeMapping(newMapping, {
636
- keepQueryContent: true,
637
- });
638
- const classes = resolveUsableDataProductClasses(
639
- this.activeFeaturedElements,
640
- newMapping,
641
- this.graphManagerState,
642
- undefined,
643
- );
644
- if (this.sourceClass && !classes.includes(this.sourceClass)) {
645
- this.setSourceElement(classes[0]);
921
+ if (!newMapping || newMapping === currentMapping) {
922
+ return;
923
+ }
924
+
925
+ const coverageResult = this.mappingToMappingCoverageResult?.get(
926
+ newMapping.path,
927
+ );
928
+
929
+ if (coverageResult && this.dataProductArtifact) {
930
+ const origin = this.graphManagerState.graph.origin;
931
+ if (origin instanceof LegendSDLC) {
932
+ const newGraph = this.graphManagerState.createNewGraph();
933
+ const projectInfo: ProjectGAVCoordinates = {
934
+ groupId: origin.groupId,
935
+ artifactId: origin.artifactId,
936
+ versionId: origin.versionId,
937
+ };
938
+ let accessPointId: string;
939
+ let dataProductAccessType: DataProductAccessType;
940
+ if (
941
+ this.executionState instanceof NativeModelDataProductExecutionState
942
+ ) {
943
+ accessPointId = this.executionState.exectionValue.key;
944
+ dataProductAccessType = DataProductAccessType.NATIVE;
945
+ } else {
946
+ accessPointId = (
947
+ this.executionState as ModelAccessPointDataProductExecutionState
948
+ ).exectionValue.id;
949
+ dataProductAccessType = DataProductAccessType.MODEL;
950
+ }
951
+ const analysisResult =
952
+ await this.graphManagerState.graphManager.buildDataProductAnalysis(
953
+ this.dataProductArtifact,
954
+ this.dataProduct.path,
955
+ newGraph,
956
+ accessPointId,
957
+ dataProductAccessType,
958
+ projectInfo,
959
+ );
960
+ this.graphManagerState.graph = newGraph;
961
+
962
+ this.dataProduct = newGraph.getDataProduct(this.dataProduct.path);
963
+ this.setExecutionState(analysisResult.targetExecState);
964
+ if (analysisResult.dataProductAnalysis.mappingToMappingCoverageResult) {
965
+ this.mappingToMappingCoverageResult =
966
+ analysisResult.dataProductAnalysis.mappingToMappingCoverageResult;
967
+ }
968
+ const newCoverageResult = this.mappingToMappingCoverageResult?.get(
969
+ newMapping.path,
970
+ );
971
+ if (newCoverageResult) {
972
+ this.explorerState.mappingModelCoverageAnalysisResult =
973
+ newCoverageResult;
974
+ }
975
+ } else {
976
+ this.explorerState.mappingModelCoverageAnalysisResult = coverageResult;
977
+ }
978
+ } else if (coverageResult) {
979
+ this.explorerState.mappingModelCoverageAnalysisResult = coverageResult;
980
+ }
981
+
982
+ await this.prepareAccessForExecution();
983
+
984
+ this.changeMapping(newMapping, {
985
+ keepQueryContent: true,
986
+ });
987
+ const classes = resolveUsableDataProductClasses(
988
+ this.activeFeaturedElements,
989
+ newMapping,
990
+ this.graphManagerState,
991
+ this.explorerState.mappingModelCoverageAnalysisResult,
992
+ );
993
+ if (
994
+ !this.sourceClass ||
995
+ (!classes.includes(this.sourceClass) && classes.length)
996
+ ) {
997
+ const possibleNewClass = classes[0];
998
+ if (possibleNewClass) {
999
+ this.changeSourceElement(possibleNewClass);
646
1000
  }
647
1001
  }
1002
+ this.explorerState.refreshTreeData();
648
1003
  }
649
1004
  }
package/tsconfig.json CHANGED
@@ -106,6 +106,7 @@
106
106
  "./src/stores/QueryLoaderState.ts",
107
107
  "./src/stores/ServiceInfo.ts",
108
108
  "./src/stores/__test-utils__/QueryBuilderStateTestUtils.ts",
109
+ "./src/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.ts",
109
110
  "./src/stores/data-access/DataAccessState.ts",
110
111
  "./src/stores/data-cube/QueryBuilderDataCubeEngine.ts",
111
112
  "./src/stores/data-cube/QueryBuilderDataCubeHelper.ts",
@@ -181,6 +182,7 @@
181
182
  "./src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Count.ts",
182
183
  "./src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Max.ts",
183
184
  "./src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Min.ts",
185
+ "./src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_PercentRank.ts",
184
186
  "./src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowOperator_Sum.ts",
185
187
  "./src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowRankOperator_AverageRank.ts",
186
188
  "./src/stores/fetch-structure/tds/window/operators/QueryBuilderTDS_WindowRankOperator_DenseRank.ts",