Skip to content

Commit a1aefa8

Browse files
fix: fix app crash on ColumnTable path type
1 parent 9bd2b0f commit a1aefa8

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
PersQueueGroupInfo,
1313
} from '../../../../components/InfoViewer/schemaInfo';
1414

15-
import {EPathType} from '../../../../types/api/schema';
15+
import {EPathType, TColumnTableDescription} from '../../../../types/api/schema';
1616
import {isColumnEntityType, isTableType} from '../../utils/schema';
1717
//@ts-ignore
1818
import {getSchema, resetLoadingState} from '../../../../store/reducers/schema';
@@ -25,7 +25,7 @@ import {useAutofetcher} from '../../../../utils/hooks';
2525

2626
import './Overview.scss';
2727

28-
function prepareOlapTableGeneral(tableData: any, olapStats?: any[]) {
28+
function prepareOlapTableGeneral(tableData: TColumnTableDescription = {}, olapStats?: any[]) {
2929
const {ColumnShardCount} = tableData;
3030
const Bytes = olapStats?.reduce((acc, el) => {
3131
acc += parseInt(el.Bytes) || 0;
@@ -103,7 +103,8 @@ function Overview(props: OverviewProps) {
103103

104104
const schemaData = useMemo(() => {
105105
return isTableType(type) && isColumnEntityType(type)
106-
? prepareOlapTableGeneral(tableSchema, olapStats)
106+
? // process data for ColumnTable
107+
prepareOlapTableGeneral(tableSchema, olapStats)
107108
: currentItem;
108109
}, [type, tableSchema, olapStats, currentItem]);
109110

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import {
2020
} from '../../../components/InfoViewer/schemaOverview';
2121
import Icon from '../../../components/Icon/Icon';
2222

23-
import {EPathSubType, EPathType, TDirEntry} from '../../../types/api/schema';
23+
import {
24+
EPathSubType,
25+
EPathType,
26+
TColumnTableDescription,
27+
TDirEntry,
28+
} from '../../../types/api/schema';
2429
import {isColumnEntityType, isIndexTable, isTableType} from '../utils/schema';
2530

2631
import {
@@ -57,19 +62,26 @@ const initialTenantCommonInfoState = {
5762
collapsed: getInitialIsSummaryCollapsed(),
5863
};
5964

60-
function prepareOlapTableSchema(tableSchema: any) {
61-
const {Name, Schema = {}} = tableSchema;
62-
const {Columns, KeyColumnNames} = Schema;
63-
const KeyColumnIds = KeyColumnNames?.map((name: string) => {
64-
const column = Columns?.find((el: any) => el.Name === name);
65-
return column.Id;
66-
});
65+
function prepareOlapTableSchema(tableSchema: TColumnTableDescription = {}) {
66+
const {Name, Schema} = tableSchema;
67+
68+
if (Schema) {
69+
const {Columns, KeyColumnNames} = Schema;
70+
const KeyColumnIds = KeyColumnNames?.map((name: string) => {
71+
const column = Columns?.find((el) => el.Name === name);
72+
return column?.Id;
73+
});
74+
75+
return {
76+
Columns,
77+
KeyColumnNames,
78+
Name,
79+
KeyColumnIds,
80+
};
81+
}
6782

6883
return {
69-
Columns,
70-
KeyColumnNames,
7184
Name,
72-
KeyColumnIds,
7385
};
7486
}
7587

@@ -118,7 +130,8 @@ function ObjectSummary(props: ObjectSummaryProps) {
118130

119131
const schema =
120132
isTableType(props.type) && isColumnEntityType(props.type)
121-
? prepareOlapTableSchema(tableSchema)
133+
? // process data for ColumnTable
134+
prepareOlapTableSchema(tableSchema)
122135
: tableSchema;
123136

124137
useEffect(() => {

0 commit comments

Comments
 (0)