@finos/legend-query-builder 4.10.1 → 4.10.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/__lib__/QueryBuilderEvent.d.ts +2 -1
- package/lib/__lib__/QueryBuilderEvent.d.ts.map +1 -1
- package/lib/__lib__/QueryBuilderEvent.js +1 -0
- package/lib/__lib__/QueryBuilderEvent.js.map +1 -1
- package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderResultPanel.js +57 -44
- package/lib/components/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +2 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts +22 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.js +24 -0
- package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
- package/lib/index.css +0 -16
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.js +2 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.js.map +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts +0 -3
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +2 -31
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +2 -0
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.js +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts +4 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js +37 -3
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts +1 -4
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js +1 -5
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.d.ts +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js +2 -2
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts +3 -2
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js +9 -0
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js +2 -4
- package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.d.ts +2 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +1 -15
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +3 -44
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +13 -3
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +3 -2
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts +2 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +2 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +2 -2
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +3 -10
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts +1 -1
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__lib__/QueryBuilderEvent.ts +1 -0
- package/src/components/QueryBuilderResultPanel.tsx +76 -63
- package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +2 -4
- package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +1 -1
- package/src/graph/QueryBuilderMetaModelConst.ts +25 -0
- package/src/index.ts +9 -2
- package/src/stores/QueryBuilderPreviewDataHelper.ts +2 -4
- package/src/stores/QueryBuilderResultState.ts +1 -36
- package/src/stores/QueryBuilderState.ts +5 -0
- package/src/stores/QueryBuilderTypeaheadHelper.ts +2 -4
- package/src/stores/fetch-structure/tds/QueryBuilderTDSHelper.ts +58 -2
- package/src/stores/fetch-structure/tds/QueryResultSetModifierState.ts +1 -5
- package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.ts +5 -9
- package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.ts +16 -2
- package/src/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.ts +2 -4
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.ts +1 -1
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +1 -50
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +22 -4
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +4 -4
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +1 -1
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +5 -5
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +5 -15
- package/src/stores/fetch-structure/tds/window/QueryBuilderWindowState.ts +1 -1
@@ -26,6 +26,7 @@ export enum QUERY_BUILDER_EVENT {
|
|
26
26
|
|
27
27
|
MAPPING_MODEL_COVERAGE_ANALYSYS__LAUNCH = 'query-builder.mapping-model-coverage-analysis.launch',
|
28
28
|
MAPPING_MODEL_COVERAGE_ANALYSYS__SUCCESS = 'query-builder.mapping-model-coverage-analysis.success',
|
29
|
+
UNSUPPORTED_QUERY_LAUNCH = 'query-builder.unsupported-query.lanuch',
|
29
30
|
}
|
30
31
|
|
31
32
|
export enum QUERY_BUILDER_FILTER_EVENT {
|
@@ -52,6 +52,7 @@ import {
|
|
52
52
|
EnumValueInstanceValue,
|
53
53
|
EnumValueExplicitReference,
|
54
54
|
RelationalExecutionActivities,
|
55
|
+
getTDSRowRankByColumnInAsc,
|
55
56
|
} from '@finos/legend-graph';
|
56
57
|
import {
|
57
58
|
ActionAlertActionType,
|
@@ -62,6 +63,8 @@ import {
|
|
62
63
|
import {
|
63
64
|
assertErrorThrown,
|
64
65
|
guaranteeNonNullable,
|
66
|
+
isBoolean,
|
67
|
+
type PlainObject,
|
65
68
|
prettyDuration,
|
66
69
|
filterByType,
|
67
70
|
isValidURL,
|
@@ -417,7 +420,9 @@ const QueryBuilderGridResultContextMenu = observer(
|
|
417
420
|
),
|
418
421
|
);
|
419
422
|
|
420
|
-
const
|
423
|
+
const findRowFromRowIndex = (
|
424
|
+
rowIndex: number,
|
425
|
+
): (string | number | boolean | null)[] => {
|
421
426
|
if (
|
422
427
|
!tdsState.queryBuilderState.resultState.executionResult ||
|
423
428
|
!(
|
@@ -425,31 +430,21 @@ const QueryBuilderGridResultContextMenu = observer(
|
|
425
430
|
TDSExecutionResult
|
426
431
|
)
|
427
432
|
) {
|
428
|
-
return '';
|
433
|
+
return [''];
|
429
434
|
}
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
.rowIndex,
|
435
|
+
return (
|
436
|
+
tdsState.queryBuilderState.resultState.executionResult.result.rows[
|
437
|
+
rowIndex
|
438
|
+
]?.values ?? ['']
|
435
439
|
);
|
436
|
-
// try to get the entire row value separated by comma
|
437
|
-
// rowData is in format of {columnName: value, columnName1: value, ...., rowNumber:value}
|
438
|
-
const valueArr: (string | number | boolean | null | undefined)[] = [];
|
439
|
-
if (rowData) {
|
440
|
-
Object.entries(rowData).forEach((entry) => {
|
441
|
-
if (entry[0] !== 'rowNumber') {
|
442
|
-
valueArr.push(entry[1]);
|
443
|
-
}
|
444
|
-
});
|
445
|
-
return valueArr.join(',');
|
446
|
-
}
|
447
|
-
return '';
|
448
440
|
};
|
449
441
|
|
450
442
|
const handleCopyRowValue = applicationStore.guardUnhandledError(() =>
|
451
443
|
applicationStore.clipboardService.copyTextToClipboard(
|
452
|
-
|
444
|
+
findRowFromRowIndex(
|
445
|
+
tdsState.queryBuilderState.resultState.selectedCells[0]?.coordinates
|
446
|
+
.rowIndex ?? 0,
|
447
|
+
).toString(),
|
453
448
|
),
|
454
449
|
);
|
455
450
|
|
@@ -507,18 +502,18 @@ const QueryResultCellRenderer = observer(
|
|
507
502
|
isString(cellValue) && isValidURL(cellValue) ? cellValue : undefined;
|
508
503
|
const columnName = params.column?.getColId() ?? '';
|
509
504
|
const findCoordinatesFromResultValue = (
|
510
|
-
|
505
|
+
colId: string,
|
511
506
|
rowNumber: number,
|
512
507
|
): QueryBuilderTDSResultCellCoordinate => {
|
513
508
|
const colIndex = tdsExecutionResult.result.columns.findIndex(
|
514
|
-
(col) => col ===
|
509
|
+
(col) => col === colId,
|
515
510
|
);
|
516
511
|
return { rowIndex: rowNumber, colIndex: colIndex };
|
517
512
|
};
|
518
513
|
|
519
514
|
const currentCellCoordinates = findCoordinatesFromResultValue(
|
520
515
|
columnName,
|
521
|
-
params.
|
516
|
+
params.rowIndex,
|
522
517
|
);
|
523
518
|
const cellInFilteredResults = resultState.selectedCells.some(
|
524
519
|
(result) =>
|
@@ -526,9 +521,9 @@ const QueryResultCellRenderer = observer(
|
|
526
521
|
result.coordinates.rowIndex === currentCellCoordinates.rowIndex,
|
527
522
|
);
|
528
523
|
|
529
|
-
const
|
524
|
+
const findColumnFromCoordinates = (
|
530
525
|
colIndex: number,
|
531
|
-
): string | undefined => {
|
526
|
+
): string | number | boolean | null | undefined => {
|
532
527
|
if (
|
533
528
|
!resultState.executionResult ||
|
534
529
|
!(resultState.executionResult instanceof TDSExecutionResult)
|
@@ -539,12 +534,30 @@ const QueryResultCellRenderer = observer(
|
|
539
534
|
};
|
540
535
|
|
541
536
|
const findResultValueFromCoordinates = (
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
537
|
+
resultCoordinate: [number, number],
|
538
|
+
): string | number | boolean | null | undefined => {
|
539
|
+
const rowIndex = resultCoordinate[0];
|
540
|
+
const colIndex = resultCoordinate[1];
|
541
|
+
|
542
|
+
if (
|
543
|
+
!resultState.executionResult ||
|
544
|
+
!(resultState.executionResult instanceof TDSExecutionResult)
|
545
|
+
) {
|
546
|
+
return undefined;
|
547
|
+
}
|
548
|
+
if (params.columnApi.getColumnState()[colIndex]?.sort === 'asc') {
|
549
|
+
resultState.executionResult.result.rows.sort((a, b) =>
|
550
|
+
getTDSRowRankByColumnInAsc(a, b, colIndex),
|
551
|
+
);
|
552
|
+
} else if (params.columnApi.getColumnState()[colIndex]?.sort === 'desc') {
|
553
|
+
resultState.executionResult.result.rows.sort((a, b) =>
|
554
|
+
getTDSRowRankByColumnInAsc(b, a, colIndex),
|
555
|
+
);
|
556
|
+
}
|
557
|
+
return resultState.executionResult.result.rows[rowIndex]?.values[
|
558
|
+
colIndex
|
559
|
+
];
|
560
|
+
};
|
548
561
|
|
549
562
|
const isCoordinatesSelected = (
|
550
563
|
resultCoordinate: QueryBuilderTDSResultCellCoordinate,
|
@@ -561,12 +574,12 @@ const QueryResultCellRenderer = observer(
|
|
561
574
|
if (event.shiftKey) {
|
562
575
|
const coordinates = findCoordinatesFromResultValue(
|
563
576
|
columnName,
|
564
|
-
params.
|
577
|
+
params.rowIndex,
|
565
578
|
);
|
566
|
-
const actualValue = findResultValueFromCoordinates(
|
579
|
+
const actualValue = findResultValueFromCoordinates([
|
567
580
|
coordinates.rowIndex,
|
568
|
-
|
569
|
-
);
|
581
|
+
coordinates.colIndex,
|
582
|
+
]);
|
570
583
|
resultState.addSelectedCell({
|
571
584
|
value: actualValue,
|
572
585
|
columnName: columnName,
|
@@ -580,12 +593,12 @@ const QueryResultCellRenderer = observer(
|
|
580
593
|
resultState.setSelectedCells([]);
|
581
594
|
const coordinates = findCoordinatesFromResultValue(
|
582
595
|
columnName,
|
583
|
-
params.
|
596
|
+
params.rowIndex,
|
584
597
|
);
|
585
|
-
const actualValue = findResultValueFromCoordinates(
|
598
|
+
const actualValue = findResultValueFromCoordinates([
|
586
599
|
coordinates.rowIndex,
|
587
|
-
|
588
|
-
);
|
600
|
+
coordinates.colIndex,
|
601
|
+
]);
|
589
602
|
resultState.setSelectedCells([
|
590
603
|
{
|
591
604
|
value: actualValue,
|
@@ -599,14 +612,14 @@ const QueryResultCellRenderer = observer(
|
|
599
612
|
if (event.button === 2) {
|
600
613
|
const coordinates = findCoordinatesFromResultValue(
|
601
614
|
columnName,
|
602
|
-
params.
|
615
|
+
params.rowIndex,
|
603
616
|
);
|
604
617
|
const isInSelected = isCoordinatesSelected(coordinates);
|
605
618
|
if (!isInSelected) {
|
606
|
-
const actualValue = findResultValueFromCoordinates(
|
619
|
+
const actualValue = findResultValueFromCoordinates([
|
607
620
|
coordinates.rowIndex,
|
608
|
-
|
609
|
-
);
|
621
|
+
coordinates.colIndex,
|
622
|
+
]);
|
610
623
|
resultState.setSelectedCells([
|
611
624
|
{
|
612
625
|
value: actualValue,
|
@@ -636,7 +649,7 @@ const QueryResultCellRenderer = observer(
|
|
636
649
|
const firstCorner = results.coordinates;
|
637
650
|
const secondCorner = findCoordinatesFromResultValue(
|
638
651
|
columnName,
|
639
|
-
params.
|
652
|
+
params.rowIndex,
|
640
653
|
);
|
641
654
|
|
642
655
|
resultState.setSelectedCells([results]);
|
@@ -648,13 +661,11 @@ const QueryResultCellRenderer = observer(
|
|
648
661
|
|
649
662
|
for (let x = minRow; x <= maxRow; x++) {
|
650
663
|
for (let y = minCol; y <= maxCol; y++) {
|
651
|
-
const actualValue = findResultValueFromCoordinates(
|
652
|
-
|
653
|
-
findColumnNameFromColumnIndex(y) as string,
|
654
|
-
);
|
664
|
+
const actualValue = findResultValueFromCoordinates([x, y]);
|
665
|
+
|
655
666
|
const valueAndColumnId = {
|
656
667
|
value: actualValue,
|
657
|
-
columnName:
|
668
|
+
columnName: findColumnFromCoordinates(y),
|
658
669
|
coordinates: {
|
659
670
|
rowIndex: x,
|
660
671
|
colIndex: y,
|
@@ -673,6 +684,7 @@ const QueryResultCellRenderer = observer(
|
|
673
684
|
}
|
674
685
|
}
|
675
686
|
}
|
687
|
+
|
676
688
|
resultState.setMouseOverCell(resultState.selectedCells[0] ?? null);
|
677
689
|
};
|
678
690
|
|
@@ -729,6 +741,20 @@ const QueryBuilderGridResult = observer(
|
|
729
741
|
|
730
742
|
const resultState = queryBuilderState.resultState;
|
731
743
|
|
744
|
+
const rowData = executionResult.result.rows.map((_row, rowIdx) => {
|
745
|
+
const row: PlainObject = {};
|
746
|
+
const cols = executionResult.result.columns;
|
747
|
+
_row.values.forEach((value, colIdx) => {
|
748
|
+
// `ag-grid` shows `false` value as empty string so we have
|
749
|
+
// call `.toString()` to avoid this behavior.
|
750
|
+
// See https://github.com/finos/legend-studio/issues/1008
|
751
|
+
row[cols[colIdx] as string] = isBoolean(value) ? String(value) : value;
|
752
|
+
});
|
753
|
+
|
754
|
+
row.rowNumber = rowIdx;
|
755
|
+
return row;
|
756
|
+
});
|
757
|
+
|
732
758
|
return (
|
733
759
|
<div className="query-builder__result__values__table">
|
734
760
|
<div
|
@@ -737,20 +763,7 @@ const QueryBuilderGridResult = observer(
|
|
737
763
|
)}
|
738
764
|
>
|
739
765
|
<DataGrid
|
740
|
-
rowData={
|
741
|
-
onSortChanged={(params) => {
|
742
|
-
const sortedData: Record<
|
743
|
-
string,
|
744
|
-
string | number | boolean | null
|
745
|
-
>[] = [];
|
746
|
-
params.api.forEachNodeAfterFilterAndSort((node, index) => {
|
747
|
-
node.rowIndex = index;
|
748
|
-
// rowNumber has to be manually updated after sorting the column
|
749
|
-
node.data.rowNumber = index;
|
750
|
-
sortedData.push(node.data);
|
751
|
-
});
|
752
|
-
queryBuilderState.resultState.setRowData(sortedData);
|
753
|
-
}}
|
766
|
+
rowData={rowData}
|
754
767
|
gridOptions={{
|
755
768
|
suppressScrollOnNewData: true,
|
756
769
|
getRowId: (data) => data.data.rowNumber,
|
@@ -32,14 +32,12 @@ import {
|
|
32
32
|
MenuContentItem,
|
33
33
|
ModalFooterButton,
|
34
34
|
} from '@finos/legend-art';
|
35
|
-
import {
|
36
|
-
COLUMN_SORT_TYPE,
|
37
|
-
SortColumnState,
|
38
|
-
} from '../../stores/fetch-structure/tds/QueryResultSetModifierState.js';
|
35
|
+
import { SortColumnState } from '../../stores/fetch-structure/tds/QueryResultSetModifierState.js';
|
39
36
|
import { guaranteeNonNullable } from '@finos/legend-shared';
|
40
37
|
import { useApplicationStore } from '@finos/legend-application';
|
41
38
|
import type { QueryBuilderTDSState } from '../../stores/fetch-structure/tds/QueryBuilderTDSState.js';
|
42
39
|
import type { QueryBuilderTDSColumnState } from '../../stores/fetch-structure/tds/QueryBuilderTDSColumnState.js';
|
40
|
+
import { COLUMN_SORT_TYPE } from '../../graph/QueryBuilderMetaModelConst.js';
|
43
41
|
|
44
42
|
const ColumnSortEditor = observer(
|
45
43
|
(props: { tdsState: QueryBuilderTDSState; sortState: SortColumnState }) => {
|
@@ -66,9 +66,9 @@ import {
|
|
66
66
|
import { QUERY_BUILDER_PROJECTION_COLUMN_DND_TYPE } from '../../stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js';
|
67
67
|
import type { QueryBuilderTDSColumnState } from '../../stores/fetch-structure/tds/QueryBuilderTDSColumnState.js';
|
68
68
|
import type { QueryBuilderTDSState } from '../../stores/fetch-structure/tds/QueryBuilderTDSState.js';
|
69
|
-
import { COLUMN_SORT_TYPE } from '../../stores/fetch-structure/tds/QueryResultSetModifierState.js';
|
70
69
|
import { QUERY_BUILDER_TEST_ID } from '../../__lib__/QueryBuilderTesting.js';
|
71
70
|
import { QueryBuilderPanelIssueCountBadge } from '../shared/QueryBuilderPanelIssueCountBadge.js';
|
71
|
+
import { COLUMN_SORT_TYPE } from '../../graph/QueryBuilderMetaModelConst.js';
|
72
72
|
|
73
73
|
// helpers
|
74
74
|
const createWindowColumnState = (
|
@@ -105,6 +105,7 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
|
|
105
105
|
TDS_GROUP_BY = 'meta::pure::tds::groupBy',
|
106
106
|
TDS_SORT = 'meta::pure::tds::sort',
|
107
107
|
TDS_TAKE = 'meta::pure::tds::take',
|
108
|
+
TDS_RESTRICT = 'meta::pure::tds::restrict',
|
108
109
|
TDS_FUNC = 'meta::pure::tds::func',
|
109
110
|
|
110
111
|
// filter
|
@@ -149,4 +150,28 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
|
|
149
150
|
FROM = 'meta::pure::mapping::from',
|
150
151
|
CHECKED = 'meta::pure::dataQuality::checked',
|
151
152
|
MERGERUNTIMES = 'meta::pure::runtime::mergeRuntimes',
|
153
|
+
|
154
|
+
// TOTDS
|
155
|
+
TABLE_TO_TDS = 'meta::pure::tds::tableToTDS',
|
156
|
+
TABLE_REFERENCE = 'meta::relational::functions::database::tableReference',
|
157
|
+
}
|
158
|
+
|
159
|
+
export enum TDS_COLUMN_GETTER {
|
160
|
+
GET_STRING = 'getString',
|
161
|
+
GET_NUMBER = 'getNumber',
|
162
|
+
GET_INTEGER = 'getInteger',
|
163
|
+
GET_FLOAT = 'getFloat',
|
164
|
+
GET_DECIMAL = 'getDecimal',
|
165
|
+
GET_DATE = 'getDate',
|
166
|
+
GET_DATETIME = 'getDateTime',
|
167
|
+
GET_STRICTDATE = 'getStrictDate',
|
168
|
+
GET_BOOLEAN = 'getBoolean',
|
169
|
+
GET_ENUM = 'getEnum',
|
170
|
+
IS_NULL = 'isNull',
|
171
|
+
IS_NOT_NULL = 'isNotNull',
|
172
|
+
}
|
173
|
+
|
174
|
+
export enum COLUMN_SORT_TYPE {
|
175
|
+
ASC = 'ASC',
|
176
|
+
DESC = 'DESC',
|
152
177
|
}
|
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 {
|
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';
|
@@ -17,15 +17,14 @@
|
|
17
17
|
import { action, flow, makeObservable, observable } from 'mobx';
|
18
18
|
import {
|
19
19
|
type GeneratorFn,
|
20
|
-
type ContentType,
|
21
20
|
assertErrorThrown,
|
22
21
|
LogEvent,
|
23
22
|
guaranteeNonNullable,
|
23
|
+
type ContentType,
|
24
24
|
downloadFileUsingDataURI,
|
25
25
|
ActionState,
|
26
26
|
StopWatch,
|
27
27
|
getContentTypeFileExtension,
|
28
|
-
isBoolean,
|
29
28
|
} from '@finos/legend-shared';
|
30
29
|
import type { QueryBuilderState } from './QueryBuilderState.js';
|
31
30
|
import {
|
@@ -38,7 +37,6 @@ import {
|
|
38
37
|
buildRawLambdaFromLambdaFunction,
|
39
38
|
reportGraphAnalytics,
|
40
39
|
extractExecutionResultValues,
|
41
|
-
TDSExecutionResult,
|
42
40
|
} from '@finos/legend-graph';
|
43
41
|
import { buildLambdaFunction } from './QueryBuilderValueSpecificationBuilder.js';
|
44
42
|
import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
|
@@ -83,7 +81,6 @@ export class QueryBuilderResultState {
|
|
83
81
|
latestRunHashCode?: string | undefined;
|
84
82
|
queryRunPromise: Promise<ExecutionResult> | undefined = undefined;
|
85
83
|
isQueryUsageViewerOpened = false;
|
86
|
-
rowData: Record<string, string | number | boolean | null>[] = [];
|
87
84
|
|
88
85
|
selectedCells: QueryBuilderTDSResultCellData[];
|
89
86
|
mousedOverCell: QueryBuilderTDSResultCellData | null = null;
|
@@ -113,8 +110,6 @@ export class QueryBuilderResultState {
|
|
113
110
|
setQueryRunPromise: action,
|
114
111
|
setIsQueryUsageViewerOpened: action,
|
115
112
|
exportData: flow,
|
116
|
-
getRowData: action,
|
117
|
-
setRowData: action,
|
118
113
|
runQuery: flow,
|
119
114
|
cancelQuery: flow,
|
120
115
|
generatePlan: flow,
|
@@ -129,36 +124,6 @@ export class QueryBuilderResultState {
|
|
129
124
|
);
|
130
125
|
}
|
131
126
|
|
132
|
-
getRowData(): Record<string, string | number | boolean | null>[] {
|
133
|
-
if (
|
134
|
-
this.executionResult &&
|
135
|
-
this.executionResult instanceof TDSExecutionResult
|
136
|
-
) {
|
137
|
-
const data = this.executionResult.result.rows.map((_row, rowIdx) => {
|
138
|
-
const row: Record<string, string | number | boolean | null> = {};
|
139
|
-
const cols = (this.executionResult as TDSExecutionResult).result
|
140
|
-
.columns;
|
141
|
-
_row.values.forEach((value, colIdx) => {
|
142
|
-
// `ag-grid` shows `false` value as empty string so we have
|
143
|
-
// call `.toString()` to avoid this behavior.
|
144
|
-
// See https://github.com/finos/legend-studio/issues/1008
|
145
|
-
row[cols[colIdx] as string] = isBoolean(value)
|
146
|
-
? String(value)
|
147
|
-
: value;
|
148
|
-
});
|
149
|
-
row.rowNumber = rowIdx;
|
150
|
-
return row;
|
151
|
-
});
|
152
|
-
this.rowData = data;
|
153
|
-
return data;
|
154
|
-
}
|
155
|
-
return [];
|
156
|
-
}
|
157
|
-
|
158
|
-
setRowData(val: Record<string, string | number | boolean | null>[]): void {
|
159
|
-
this.rowData = val;
|
160
|
-
}
|
161
|
-
|
162
127
|
setIsSelectingCells(val: boolean): void {
|
163
128
|
this.isSelectingCells = val;
|
164
129
|
}
|
@@ -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 {
|
30
|
+
import {
|
31
|
+
COLUMN_SORT_TYPE,
|
32
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
33
|
+
TDS_COLUMN_GETTER,
|
34
|
+
} from '../../../graph/QueryBuilderMetaModelConst.js';
|
26
35
|
import type { QueryBuilderTDSState } from './QueryBuilderTDSState.js';
|
27
36
|
import type { QueryBuilderTDSColumnState } from './QueryBuilderTDSColumnState.js';
|
28
|
-
import { COLUMN_SORT_TYPE } from './QueryResultSetModifierState.js';
|
29
37
|
|
30
38
|
export const findTDSColumnState = (
|
31
39
|
projectionState: QueryBuilderTDSState,
|
@@ -77,3 +85,51 @@ export const getFunctionNameFromTDSSortColumn = (
|
|
77
85
|
);
|
78
86
|
}
|
79
87
|
};
|
88
|
+
|
89
|
+
export const buildTDSSortTypeExpression = (
|
90
|
+
sortType: COLUMN_SORT_TYPE,
|
91
|
+
column: string,
|
92
|
+
): SimpleFunctionExpression => {
|
93
|
+
const sortColumnFunction = new SimpleFunctionExpression(
|
94
|
+
extractElementNameFromPath(
|
95
|
+
sortType === COLUMN_SORT_TYPE.ASC
|
96
|
+
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_ASC
|
97
|
+
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_DESC,
|
98
|
+
),
|
99
|
+
);
|
100
|
+
const sortColumnName = createPrimitiveInstance_String(column);
|
101
|
+
sortColumnFunction.parametersValues[0] = sortColumnName;
|
102
|
+
return sortColumnFunction;
|
103
|
+
};
|
104
|
+
|
105
|
+
export const getTDSColumnDerivedProperyFromType = (
|
106
|
+
type: Type,
|
107
|
+
): TDS_COLUMN_GETTER => {
|
108
|
+
if (type instanceof Enumeration) {
|
109
|
+
return TDS_COLUMN_GETTER.GET_ENUM;
|
110
|
+
}
|
111
|
+
switch (type.path) {
|
112
|
+
case PRIMITIVE_TYPE.STRING:
|
113
|
+
return TDS_COLUMN_GETTER.GET_STRING;
|
114
|
+
case PRIMITIVE_TYPE.NUMBER:
|
115
|
+
return TDS_COLUMN_GETTER.GET_NUMBER;
|
116
|
+
case PRIMITIVE_TYPE.INTEGER:
|
117
|
+
return TDS_COLUMN_GETTER.GET_INTEGER;
|
118
|
+
case PRIMITIVE_TYPE.FLOAT:
|
119
|
+
return TDS_COLUMN_GETTER.GET_FLOAT;
|
120
|
+
case PRIMITIVE_TYPE.DECIMAL:
|
121
|
+
return TDS_COLUMN_GETTER.GET_DECIMAL;
|
122
|
+
case PRIMITIVE_TYPE.DATE:
|
123
|
+
return TDS_COLUMN_GETTER.GET_DATE;
|
124
|
+
case PRIMITIVE_TYPE.DATETIME:
|
125
|
+
return TDS_COLUMN_GETTER.GET_DATETIME;
|
126
|
+
case PRIMITIVE_TYPE.STRICTDATE:
|
127
|
+
return TDS_COLUMN_GETTER.GET_STRICTDATE;
|
128
|
+
case PRIMITIVE_TYPE.BOOLEAN:
|
129
|
+
return TDS_COLUMN_GETTER.GET_BOOLEAN;
|
130
|
+
default:
|
131
|
+
throw new UnsupportedOperationError(
|
132
|
+
`Can't find TDS column derived property name for type: '${type.path}'`,
|
133
|
+
);
|
134
|
+
}
|
135
|
+
};
|
@@ -24,11 +24,7 @@ import {
|
|
24
24
|
} from '@finos/legend-shared';
|
25
25
|
import { QUERY_BUILDER_STATE_HASH_STRUCTURE } from '../../QueryBuilderStateHashUtils.js';
|
26
26
|
import type { QueryBuilderTDSColumnState } from './QueryBuilderTDSColumnState.js';
|
27
|
-
|
28
|
-
export enum COLUMN_SORT_TYPE {
|
29
|
-
ASC = 'ASC',
|
30
|
-
DESC = 'DESC',
|
31
|
-
}
|
27
|
+
import { COLUMN_SORT_TYPE } from '../../../graph/QueryBuilderMetaModelConst.js';
|
32
28
|
|
33
29
|
export class SortColumnState implements Hashable {
|
34
30
|
columnState: QueryBuilderTDSColumnState;
|
@@ -14,11 +14,7 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import {
|
18
|
-
uuid,
|
19
|
-
guaranteeNonNullable,
|
20
|
-
type Hashable,
|
21
|
-
} from '@finos/legend-shared';
|
17
|
+
import { uuid, type Hashable } from '@finos/legend-shared';
|
22
18
|
import type {
|
23
19
|
AbstractPropertyExpression,
|
24
20
|
PureModel,
|
@@ -82,10 +78,10 @@ export abstract class QueryBuilderAggregateOperator implements Hashable {
|
|
82
78
|
* Returns the expected return type of the operator.
|
83
79
|
* defaults to using the return type of the projection column state which is being aggregated.
|
84
80
|
*/
|
85
|
-
getReturnType(
|
86
|
-
|
87
|
-
|
88
|
-
);
|
81
|
+
getReturnType(
|
82
|
+
aggregateColumnState: QueryBuilderAggregateColumnState,
|
83
|
+
): Type | undefined {
|
84
|
+
return aggregateColumnState.projectionColumnState.getColumnType();
|
89
85
|
}
|
90
86
|
|
91
87
|
abstract get hashCode(): string;
|
@@ -25,7 +25,10 @@ import type { Type } from '@finos/legend-graph';
|
|
25
25
|
import { DEFAULT_LAMBDA_VARIABLE_NAME } from '../../../QueryBuilderConfig.js';
|
26
26
|
import type { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
27
27
|
import type { QueryBuilderAggregateOperator } from './QueryBuilderAggregateOperator.js';
|
28
|
-
import
|
28
|
+
import {
|
29
|
+
QueryBuilderDerivationProjectionColumnState,
|
30
|
+
type QueryBuilderProjectionColumnState,
|
31
|
+
} from '../projection/QueryBuilderProjectionColumnState.js';
|
29
32
|
import { QUERY_BUILDER_STATE_HASH_STRUCTURE } from '../../../QueryBuilderStateHashUtils.js';
|
30
33
|
import { QueryBuilderTDSColumnState } from '../QueryBuilderTDSColumnState.js';
|
31
34
|
import type { QueryBuilderAggregateCalendarFunction } from './QueryBuilderAggregateCalendarFunction.js';
|
@@ -58,6 +61,7 @@ export class QueryBuilderAggregateColumnState
|
|
58
61
|
setLambdaParameterName: action,
|
59
62
|
setOperator: action,
|
60
63
|
setCalendarFunction: action,
|
64
|
+
handleUsedPostFilterType: action,
|
61
65
|
hashCode: computed,
|
62
66
|
});
|
63
67
|
|
@@ -88,10 +92,20 @@ export class QueryBuilderAggregateColumnState
|
|
88
92
|
this.operator = val;
|
89
93
|
}
|
90
94
|
|
91
|
-
getColumnType(): Type {
|
95
|
+
getColumnType(): Type | undefined {
|
92
96
|
return this.operator.getReturnType(this);
|
93
97
|
}
|
94
98
|
|
99
|
+
handleUsedPostFilterType(type: Type): void {
|
100
|
+
if (
|
101
|
+
this.getColumnType() === undefined &&
|
102
|
+
this.projectionColumnState instanceof
|
103
|
+
QueryBuilderDerivationProjectionColumnState
|
104
|
+
) {
|
105
|
+
this.projectionColumnState.setReturnType(type);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
95
109
|
get hashCode(): string {
|
96
110
|
return hashArray([
|
97
111
|
QUERY_BUILDER_STATE_HASH_STRUCTURE.AGGREGATE_COLUMN_STATE,
|