@finos/legend-query-builder 4.18.1 → 4.18.3

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 (122) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +0 -1
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderSideBar.js +10 -2
  6. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  7. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  8. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +5 -3
  9. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  10. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  11. package/lib/components/filter/QueryBuilderFilterPanel.js +74 -36
  12. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  13. package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.d.ts.map +1 -1
  14. package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.js +15 -3
  15. package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.js.map +1 -1
  16. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
  17. package/lib/components/result/tds/QueryBuilderTDSResultShared.js +5 -3
  18. package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
  19. package/lib/components/sql-playground/SQLPlaygroundPanel.d.ts.map +1 -1
  20. package/lib/components/sql-playground/SQLPlaygroundPanel.js +9 -5
  21. package/lib/components/sql-playground/SQLPlaygroundPanel.js.map +1 -1
  22. package/lib/data-access-overview.css +1 -1
  23. package/lib/index.css +1 -17
  24. package/lib/index.css.map +1 -1
  25. package/lib/index.d.ts +1 -1
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +1 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/package.json +1 -1
  30. package/lib/stores/QueryBuilderStateBuilder.d.ts +1 -1
  31. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  32. package/lib/stores/QueryBuilderStateBuilder.js +10 -2
  33. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  34. package/lib/stores/QueryBuilderStateHashUtils.d.ts +2 -0
  35. package/lib/stores/QueryBuilderStateHashUtils.d.ts.map +1 -1
  36. package/lib/stores/QueryBuilderStateHashUtils.js +2 -0
  37. package/lib/stores/QueryBuilderStateHashUtils.js.map +1 -1
  38. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.d.ts +98 -0
  39. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.d.ts.map +1 -1
  40. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.js +156 -0
  41. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.js.map +1 -1
  42. package/lib/stores/filter/QueryBuilderFilterState.d.ts +50 -4
  43. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  44. package/lib/stores/filter/QueryBuilderFilterState.js +112 -11
  45. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  46. package/lib/stores/filter/QueryBuilderFilterStateBuilder.d.ts.map +1 -1
  47. package/lib/stores/filter/QueryBuilderFilterStateBuilder.js +17 -3
  48. package/lib/stores/filter/QueryBuilderFilterStateBuilder.js.map +1 -1
  49. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts +6 -0
  50. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
  51. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js +35 -9
  52. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js.map +1 -1
  53. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts.map +1 -1
  54. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js +2 -4
  55. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js.map +1 -1
  56. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts.map +1 -1
  57. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js +2 -4
  58. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js.map +1 -1
  59. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts.map +1 -1
  60. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js +7 -11
  61. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js.map +1 -1
  62. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts.map +1 -1
  63. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js +7 -11
  64. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js.map +1 -1
  65. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts.map +1 -1
  66. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js +7 -11
  67. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js.map +1 -1
  68. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.d.ts.map +1 -1
  69. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js +3 -6
  70. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js.map +1 -1
  71. package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts +1 -1
  72. package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts.map +1 -1
  73. package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js +5 -3
  74. package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js.map +1 -1
  75. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts.map +1 -1
  76. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js +7 -11
  77. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js.map +1 -1
  78. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts.map +1 -1
  79. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js +7 -11
  80. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js.map +1 -1
  81. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts.map +1 -1
  82. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js +2 -4
  83. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js.map +1 -1
  84. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
  85. package/lib/stores/milestoning/QueryBuilderMilestoningState.js +9 -6
  86. package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
  87. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.d.ts +1 -2
  88. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.d.ts.map +1 -1
  89. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.js +1 -3
  90. package/lib/stores/workflows/accessor/AccessorQueryBuilderState.js.map +1 -1
  91. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.d.ts +11 -6
  92. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.d.ts.map +1 -1
  93. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.js +150 -49
  94. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.js.map +1 -1
  95. package/package.json +10 -10
  96. package/src/components/QueryBuilder.tsx +0 -1
  97. package/src/components/QueryBuilderSideBar.tsx +10 -7
  98. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +7 -2
  99. package/src/components/filter/QueryBuilderFilterPanel.tsx +138 -69
  100. package/src/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.tsx +33 -3
  101. package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +4 -1
  102. package/src/components/sql-playground/SQLPlaygroundPanel.tsx +10 -5
  103. package/src/index.ts +1 -1
  104. package/src/stores/QueryBuilderStateBuilder.ts +15 -2
  105. package/src/stores/QueryBuilderStateHashUtils.ts +2 -0
  106. package/src/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.ts +157 -0
  107. package/src/stores/filter/QueryBuilderFilterState.ts +175 -14
  108. package/src/stores/filter/QueryBuilderFilterStateBuilder.ts +24 -3
  109. package/src/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.ts +55 -24
  110. package/src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts +2 -5
  111. package/src/stores/filter/operators/QueryBuilderFilterOperator_EndWith.ts +2 -5
  112. package/src/stores/filter/operators/QueryBuilderFilterOperator_Equal.ts +7 -13
  113. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.ts +7 -13
  114. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.ts +7 -13
  115. package/src/stores/filter/operators/QueryBuilderFilterOperator_In.ts +3 -9
  116. package/src/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.ts +9 -6
  117. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThan.ts +7 -13
  118. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.ts +7 -13
  119. package/src/stores/filter/operators/QueryBuilderFilterOperator_StartWith.ts +2 -5
  120. package/src/stores/milestoning/QueryBuilderMilestoningState.ts +13 -7
  121. package/src/stores/workflows/accessor/AccessorQueryBuilderState.ts +1 -3
  122. package/src/stores/workflows/dataProduct/DataProductQueryBuilderState.ts +245 -76
@@ -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,
@@ -53,6 +54,10 @@ import {
53
54
  GenericTypeExplicitReference,
54
55
  findLakehouseAccessPointGroup,
55
56
  type PureModel,
57
+ V1_RelationType,
58
+ V1_getGenericTypeFullPath,
59
+ LegendSDLC,
60
+ DataProductAccessType,
56
61
  } from '@finos/legend-graph';
57
62
  import { QueryBuilderState } from '../../QueryBuilderState.js';
58
63
 
@@ -74,27 +79,64 @@ import { action, computed, flow, makeObservable, observable } from 'mobx';
74
79
  import {
75
80
  DepotEntityWithOrigin,
76
81
  type QueryableSourceInfo,
82
+ type ProjectGAVCoordinates,
77
83
  } from '@finos/legend-storage';
78
84
  import { compareLabelFn } from '@finos/legend-art';
79
85
  import { QueryBuilderEmbeddedFromExecutionContextState } from '../../QueryBuilderExecutionContextState.js';
80
86
  import { buildLambdaFunction } from '../../QueryBuilderValueSpecificationBuilder.js';
81
87
 
82
- export const buildDataProductAccessor = (
83
- relationMetadata: RelationTypeMetadata,
88
+ export const resolveDataProductAccessor = (
84
89
  dataProduct: DataProduct,
85
90
  accessPoint: LakehouseAccessPoint,
86
91
  graph: PureModel,
92
+ artifact: V1_DataProductArtifact | undefined,
93
+ relationMetadata?: RelationTypeMetadata | undefined,
87
94
  ): DataProductAccessor => {
88
95
  const relationType = new RelationType(accessPoint.title ?? accessPoint.id);
89
- relationType.columns = relationMetadata.columns.map(
90
- (col) =>
91
- new RelationColumn(
92
- col.name,
93
- GenericTypeExplicitReference.create(
94
- new GenericType(graph.getType(col.type)),
95
- ),
96
+ if (artifact) {
97
+ const artifactGroup = artifact.accessPointGroups.find((apg) =>
98
+ apg.accessPointImplementations.some(
99
+ (apImpl) => apImpl.id === accessPoint.id,
96
100
  ),
97
- );
101
+ );
102
+ const artifactImpl = artifactGroup?.accessPointImplementations.find(
103
+ (apImpl) => apImpl.id === accessPoint.id,
104
+ );
105
+ const v1RelationType = artifactImpl?.lambdaGenericType?.typeArguments
106
+ .map((typeArg) => typeArg.rawType)
107
+ .find((rawType) => rawType instanceof V1_RelationType);
108
+ if (v1RelationType) {
109
+ relationType.columns = v1RelationType.columns.map(
110
+ (col) =>
111
+ new RelationColumn(
112
+ col.name,
113
+ GenericTypeExplicitReference.create(
114
+ new GenericType(
115
+ graph.getType(V1_getGenericTypeFullPath(col.genericType)),
116
+ ),
117
+ ),
118
+ ),
119
+ );
120
+ return new DataProductAccessor(
121
+ dataProduct.path,
122
+ artifactGroup?.id,
123
+ accessPoint.id,
124
+ relationType,
125
+ dataProduct,
126
+ );
127
+ }
128
+ }
129
+ if (relationMetadata) {
130
+ relationType.columns = relationMetadata.columns.map(
131
+ (col) =>
132
+ new RelationColumn(
133
+ col.name,
134
+ GenericTypeExplicitReference.create(
135
+ new GenericType(graph.getType(col.type)),
136
+ ),
137
+ ),
138
+ );
139
+ }
98
140
  const groupResult = findLakehouseAccessPointGroup(
99
141
  dataProduct,
100
142
  accessPoint.id,
@@ -268,7 +310,9 @@ export class LakehouseDataProductExecutionState extends DataProductExecutionStat
268
310
  queryBuilderState: DataProductQueryBuilderState,
269
311
  ) {
270
312
  super(executionState, queryBuilderState);
271
- makeObservable(this, {});
313
+ makeObservable(this, {
314
+ withAdhocRuntime: observable,
315
+ });
272
316
  this.selectedRuntime = this.compatibleRuntimes[0];
273
317
  }
274
318
 
@@ -277,6 +321,11 @@ export class LakehouseDataProductExecutionState extends DataProductExecutionStat
277
321
  this.queryBuilderState.changeRuntime(val);
278
322
  }
279
323
 
324
+ withAdhocRuntime(): LakehouseDataProductExecutionState {
325
+ this.adhocRuntime = true;
326
+ return this;
327
+ }
328
+
280
329
  override get label(): string {
281
330
  return this.exectionValue.title ?? this.exectionValue.id;
282
331
  }
@@ -303,9 +352,6 @@ export class LakehouseDataProductExecutionState extends DataProductExecutionStat
303
352
  export class DataProductQueryBuilderState extends QueryBuilderState {
304
353
  readonly onClassChange?: ((val: Class) => void) | undefined;
305
354
  readonly onDataProductChange?: (val: DepotEntityWithOrigin) => Promise<void>;
306
- readonly onExecutionContextChange?:
307
- | ((val: NativeModelExecutionContext) => void)
308
- | undefined;
309
355
 
310
356
  loadDataProductModelState = ActionState.create();
311
357
  dataProduct: DataProduct;
@@ -314,6 +360,10 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
314
360
  NativeModelExecutionContext | ModelAccessPointGroup | LakehouseAccessPoint
315
361
  >;
316
362
  entities: DepotEntityWithOrigin[] | undefined;
363
+ mappingToMappingCoverageResult?: Map<
364
+ string,
365
+ MappingModelCoverageAnalysisResult
366
+ >;
317
367
 
318
368
  prioritizeEntityFunc?: ((val: DepotEntityWithOrigin) => boolean) | undefined;
319
369
 
@@ -333,9 +383,6 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
333
383
  | LakehouseAccessPoint,
334
384
  prioritizeEntityFunc: ((val: DepotEntityWithOrigin) => boolean) | undefined,
335
385
  onDataProductChange: (val: DepotEntityWithOrigin) => Promise<void>,
336
- onExecutionContextChange?:
337
- | ((val: NativeModelExecutionContext) => void)
338
- | undefined,
339
386
  onClassChange?: ((val: Class) => void) | undefined,
340
387
  config?: QueryBuilderConfig | undefined,
341
388
  sourceInfo?: QueryableSourceInfo | undefined,
@@ -357,6 +404,11 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
357
404
  showExecutionIdSelector: computed,
358
405
  executionIdOptions: computed,
359
406
  selectedExecutionIdOption: computed,
407
+ hasNativeModelAccess: computed,
408
+ hasBothAccessModes: computed,
409
+ showContextSelector: computed,
410
+ allContextOptions: computed,
411
+ selectedContextOption: computed,
360
412
  selectedExecOption: computed,
361
413
  selectedModelAccessPointGroupOption: computed,
362
414
  usableClasses: computed,
@@ -382,13 +434,44 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
382
434
  : new ModelAccessPointDataProductExecutionState(executionState, this);
383
435
  this.prioritizeEntityFunc = prioritizeEntityFunc;
384
436
  this.onDataProductChange = onDataProductChange;
385
- this.onExecutionContextChange = onExecutionContextChange;
386
437
  this.onClassChange = onClassChange;
387
438
  // force from.
388
439
  this.executionContextState =
389
440
  new QueryBuilderEmbeddedFromExecutionContextState(this);
390
441
  }
391
442
 
443
+ async prepareAccessForExecution(): Promise<void> {
444
+ if (this.executionState instanceof NativeModelDataProductExecutionState) {
445
+ const runtime = this.executionState.exectionValue.runtime;
446
+ if (runtime) {
447
+ this.changeRuntime(new RuntimePointer(runtime));
448
+ }
449
+ } else if (
450
+ this.executionState instanceof
451
+ ModelAccessPointDataProductExecutionState &&
452
+ this.executionState.selectedRuntime
453
+ ) {
454
+ this.changeRuntime(
455
+ new RuntimePointer(
456
+ PackageableElementExplicitReference.create(
457
+ this.executionState.selectedRuntime,
458
+ ),
459
+ ),
460
+ );
461
+ } else if (
462
+ this.executionState instanceof LakehouseDataProductExecutionState &&
463
+ this.executionState.selectedRuntime
464
+ ) {
465
+ this.changeRuntime(
466
+ new RuntimePointer(
467
+ PackageableElementExplicitReference.create(
468
+ this.executionState.selectedRuntime,
469
+ ),
470
+ ),
471
+ );
472
+ }
473
+ }
474
+
392
475
  get isProductLinkable(): boolean {
393
476
  return false;
394
477
  }
@@ -417,19 +500,40 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
417
500
  this.modelAccessPointGroupOptions.length > 1
418
501
  );
419
502
  }
503
+ get hasNativeModelAccess(): boolean {
504
+ return this.dataProduct.nativeModelAccess !== undefined;
505
+ }
506
+
507
+ get hasBothAccessModes(): boolean {
508
+ return this.hasModelAccessPointGroups && this.hasNativeModelAccess;
509
+ }
510
+
511
+ // showContextSelector / allContextOptions / selectedContextOption are aliases
512
+ // over the upstream ExecutionIdOption API so existing UI code keeps working.
513
+ get showContextSelector(): boolean {
514
+ return this.showExecutionIdSelector;
515
+ }
516
+
517
+ get allContextOptions(): ExecutionIdOption[] {
518
+ return this.executionIdOptions;
519
+ }
520
+
521
+ get selectedContextOption(): ExecutionIdOption | undefined {
522
+ return this.selectedExecutionIdOption;
523
+ }
420
524
 
421
525
  get executionIdOptions(): ExecutionIdOption[] {
422
526
  const nativeOptions: ExecutionIdOption[] = (
423
527
  this.dataProduct.nativeModelAccess?.nativeModelExecutionContexts ?? []
424
528
  ).map((ctx) => ({
425
529
  label: ctx.key,
426
- tag: 'Native',
530
+ tag: 'NATIVE',
427
531
  value: ctx,
428
532
  }));
429
533
  const modelOptions: ExecutionIdOption[] = this.modelAccessPointGroups.map(
430
534
  (group) => ({
431
535
  label: group.title ?? group.id,
432
- tag: 'Model',
536
+ tag: 'MODEL',
433
537
  value: group,
434
538
  }),
435
539
  );
@@ -439,7 +543,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
439
543
  .filter(filterByType(LakehouseAccessPoint))
440
544
  .map((ap) => ({
441
545
  label: ap.title ?? ap.id,
442
- tag: 'Lakehouse',
546
+ tag: 'LAKEHOUSE',
443
547
  value: ap,
444
548
  }));
445
549
  return [...modelOptions, ...lakehouseOptions, ...nativeOptions].sort(
@@ -452,19 +556,19 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
452
556
  if (state instanceof NativeModelDataProductExecutionState) {
453
557
  return {
454
558
  label: state.exectionValue.key,
455
- tag: 'Native',
559
+ tag: 'NATIVE',
456
560
  value: state.exectionValue,
457
561
  };
458
562
  } else if (state instanceof ModelAccessPointDataProductExecutionState) {
459
563
  return {
460
564
  label: state.exectionValue.title ?? state.exectionValue.id,
461
- tag: 'Model',
565
+ tag: 'MODEL',
462
566
  value: state.exectionValue,
463
567
  };
464
568
  } else if (state instanceof LakehouseDataProductExecutionState) {
465
569
  return {
466
570
  label: state.exectionValue.title ?? state.exectionValue.id,
467
- tag: 'Lakehouse',
571
+ tag: 'LAKEHOUSE',
468
572
  value: state.exectionValue,
469
573
  };
470
574
  }
@@ -480,11 +584,20 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
480
584
  if (val === this.executionState.exectionValue) {
481
585
  return;
482
586
  }
587
+ const switchingToModel = val instanceof ModelAccessPointGroup;
588
+ const switchingToNative = val instanceof NativeModelExecutionContext;
589
+ const wasModeSwitch =
590
+ (switchingToModel && this.isNativeMode) ||
591
+ (switchingToNative && this.isModelAccessPointGroupMode);
592
+
593
+ if (wasModeSwitch) {
594
+ this.changeHistoryState.querySnapshotBuffer = [];
595
+ this.changeHistoryState.pointer = -1;
596
+ this.changeHistoryState.setCurrentQuery(undefined);
597
+ }
598
+
483
599
  await this.changeExecutionState(val);
484
600
  await this.propagateExecutionContextChange();
485
- if (val instanceof NativeModelExecutionContext) {
486
- this.onExecutionContextChange?.(val);
487
- }
488
601
  }
489
602
 
490
603
  get selectedExecOption():
@@ -523,29 +636,6 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
523
636
  : [];
524
637
  }
525
638
 
526
- changeNativeExecutionContext(val: NativeModelExecutionContext): void {
527
- if (this.isNativeMode && val === this.executionState.exectionValue) {
528
- return;
529
- }
530
- this.setExecutionState(val);
531
- this.propagateExecutionContextChange()
532
- .then(() => this.onExecutionContextChange?.(val))
533
- .catch(this.applicationStore.alertUnhandledError);
534
- }
535
-
536
- changeModelAccessPointGroupValue(val: ModelAccessPointGroup): void {
537
- if (
538
- this.isModelAccessPointGroupMode &&
539
- val === this.executionState.exectionValue
540
- ) {
541
- return;
542
- }
543
- this.setExecutionState(val);
544
- this.propagateExecutionContextChange().catch(
545
- this.applicationStore.alertUnhandledError,
546
- );
547
- }
548
-
549
639
  override buildQueryForPersistence(): RawLambda {
550
640
  if (!this.isQuerySupported) {
551
641
  return this.buildQuery();
@@ -580,7 +670,9 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
580
670
  ) {
581
671
  const execContext = new QueryDataProductLakehouseExecutionContext();
582
672
  execContext.dataProductPath = this.dataProduct.path;
673
+ execContext.accessGroupId = this.executionState.exectionValue.__owner.id;
583
674
  execContext.accessPointId = this.executionState.exectionValue.id;
675
+
584
676
  return execContext;
585
677
  }
586
678
  return super.getQueryExecutionContext();
@@ -632,12 +724,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
632
724
  const execValue =
633
725
  preResolvedState ?? resolveDataProductExecutionState(dataProduct);
634
726
  this.dataProduct = dataProduct;
635
- this.executionState =
636
- execValue instanceof NativeModelExecutionContext
637
- ? new NativeModelDataProductExecutionState(execValue, this)
638
- : execValue instanceof LakehouseAccessPoint
639
- ? new LakehouseDataProductExecutionState(execValue, this)
640
- : new ModelAccessPointDataProductExecutionState(execValue, this);
727
+ this.setExecutionState(execValue);
641
728
  const mapping = this.executionState.mapping;
642
729
  if (mapping) {
643
730
  this.changeMapping(mapping);
@@ -669,11 +756,18 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
669
756
  );
670
757
  }
671
758
  if (mapping) {
759
+ const coverageResult = this.mappingToMappingCoverageResult?.get(
760
+ mapping.path,
761
+ );
762
+ if (coverageResult) {
763
+ this.explorerState.mappingModelCoverageAnalysisResult =
764
+ coverageResult;
765
+ }
672
766
  const compatibleClasses = resolveUsableDataProductClasses(
673
767
  this.activeFeaturedElements,
674
768
  mapping,
675
769
  this.graphManagerState,
676
- undefined,
770
+ coverageResult,
677
771
  );
678
772
  // if there is no chosen class or the chosen one is not compatible
679
773
  // with the mapping then pick a compatible class if possible
@@ -729,16 +823,18 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
729
823
  ): Promise<void> {
730
824
  this.setExecutionState(val);
731
825
  if (val instanceof LakehouseAccessPoint) {
732
- const relationMetadata =
733
- await this.graphManagerState.graphManager.getLambdaRelationType(
734
- val.func,
735
- this.graphManagerState.graph,
736
- );
737
- const accessor = buildDataProductAccessor(
738
- relationMetadata,
826
+ const relationMetadata = !this.dataProductArtifact
827
+ ? await this.graphManagerState.graphManager.getLambdaRelationType(
828
+ val.func,
829
+ this.graphManagerState.graph,
830
+ )
831
+ : undefined;
832
+ const accessor = resolveDataProductAccessor(
739
833
  this.dataProduct,
740
834
  val,
741
835
  this.graphManagerState.graph,
836
+ this.dataProductArtifact,
837
+ relationMetadata,
742
838
  );
743
839
  this.setSourceElement(accessor);
744
840
  }
@@ -882,19 +978,92 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
882
978
  ): Promise<void> {
883
979
  const currentMapping = this.executionContextState.mapping;
884
980
  const newMapping = this.activeMapping;
885
- if (newMapping && newMapping !== currentMapping) {
886
- this.changeMapping(newMapping, {
887
- keepQueryContent: true,
888
- });
889
- const classes = resolveUsableDataProductClasses(
890
- this.activeFeaturedElements,
891
- newMapping,
892
- this.graphManagerState,
893
- undefined,
894
- );
895
- if (this.sourceClass && !classes.includes(this.sourceClass)) {
896
- this.setSourceElement(classes[0]);
981
+ if (!newMapping || newMapping === currentMapping) {
982
+ return;
983
+ }
984
+
985
+ const coverageResult = this.mappingToMappingCoverageResult?.get(
986
+ newMapping.path,
987
+ );
988
+
989
+ if (coverageResult && this.dataProductArtifact) {
990
+ const origin = this.graphManagerState.graph.origin;
991
+ if (origin instanceof LegendSDLC) {
992
+ const newGraph = this.graphManagerState.createNewGraph();
993
+ const projectInfo: ProjectGAVCoordinates = {
994
+ groupId: origin.groupId,
995
+ artifactId: origin.artifactId,
996
+ versionId: origin.versionId,
997
+ };
998
+ let accessPointId: string;
999
+ let dataProductAccessType: DataProductAccessType;
1000
+ if (
1001
+ this.executionState instanceof NativeModelDataProductExecutionState
1002
+ ) {
1003
+ accessPointId = this.executionState.exectionValue.key;
1004
+ dataProductAccessType = DataProductAccessType.NATIVE;
1005
+ } else if (
1006
+ this.executionState instanceof LakehouseDataProductExecutionState
1007
+ ) {
1008
+ accessPointId = this.executionState.exectionValue.id;
1009
+ dataProductAccessType = DataProductAccessType.LAKEHOUSE;
1010
+ } else {
1011
+ accessPointId = (
1012
+ this.executionState as ModelAccessPointDataProductExecutionState
1013
+ ).exectionValue.id;
1014
+ dataProductAccessType = DataProductAccessType.MODEL;
1015
+ }
1016
+ const analysisResult =
1017
+ await this.graphManagerState.graphManager.buildDataProductAnalysis(
1018
+ this.dataProductArtifact,
1019
+ this.dataProduct.path,
1020
+ newGraph,
1021
+ accessPointId,
1022
+ dataProductAccessType,
1023
+ projectInfo,
1024
+ );
1025
+ this.graphManagerState.graph = newGraph;
1026
+
1027
+ this.dataProduct = newGraph.getDataProduct(this.dataProduct.path);
1028
+ this.setExecutionState(analysisResult.targetExecState);
1029
+ if (analysisResult.dataProductAnalysis.mappingToMappingCoverageResult) {
1030
+ this.mappingToMappingCoverageResult =
1031
+ analysisResult.dataProductAnalysis.mappingToMappingCoverageResult;
1032
+ }
1033
+ const newCoverageResult = this.mappingToMappingCoverageResult?.get(
1034
+ newMapping.path,
1035
+ );
1036
+ if (newCoverageResult) {
1037
+ this.explorerState.mappingModelCoverageAnalysisResult =
1038
+ newCoverageResult;
1039
+ }
1040
+ } else {
1041
+ this.explorerState.mappingModelCoverageAnalysisResult = coverageResult;
1042
+ }
1043
+ } else if (coverageResult) {
1044
+ this.explorerState.mappingModelCoverageAnalysisResult = coverageResult;
1045
+ }
1046
+
1047
+ await this.prepareAccessForExecution();
1048
+
1049
+ this.changeMapping(newMapping, {
1050
+ keepQueryContent: true,
1051
+ });
1052
+ const classes = resolveUsableDataProductClasses(
1053
+ this.activeFeaturedElements,
1054
+ newMapping,
1055
+ this.graphManagerState,
1056
+ this.explorerState.mappingModelCoverageAnalysisResult,
1057
+ );
1058
+ if (
1059
+ !this.sourceClass ||
1060
+ (!classes.includes(this.sourceClass) && classes.length)
1061
+ ) {
1062
+ const possibleNewClass = classes[0];
1063
+ if (possibleNewClass) {
1064
+ this.changeSourceElement(possibleNewClass);
897
1065
  }
898
1066
  }
1067
+ this.explorerState.refreshTreeData();
899
1068
  }
900
1069
  }