Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/containers/Tenant/Diagnostics/DiagnosticsPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const SERVERLESS_DATABASE_PAGES = [

const TABLE_PAGES = [overview, schema, topShards, nodes, graph, tablets, hotKeys, describe, access];
const COLUMN_TABLE_PAGES = [overview, schema, topShards, nodes, tablets, describe, access];
const SYSTEM_VIEW_PAGES = [overview, schema, nodes, describe, access];

const DIR_PAGES = [overview, topShards, nodes, describe, access];

Expand All @@ -164,6 +165,7 @@ const pathTypeToPages: Record<EPathType, Page[] | undefined> = {

[EPathType.EPathTypeTable]: TABLE_PAGES,
[EPathType.EPathTypeColumnTable]: COLUMN_TABLE_PAGES,
[EPathType.EPathTypeSysView]: SYSTEM_VIEW_PAGES,

[EPathType.EPathTypeDir]: DIR_PAGES,
[EPathType.EPathTypeTableIndex]: DIR_PAGES,
Expand Down
2 changes: 2 additions & 0 deletions src/containers/Tenant/Diagnostics/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {EPathType} from '../../../../types/api/schema';
import {useAutoRefreshInterval} from '../../../../utils/hooks';
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
import {ExternalTableInfo} from '../../Info/ExternalTable/ExternalTable';
import {SystemViewInfo} from '../../Info/SystemView/SystemView';
import {ViewInfo} from '../../Info/View/View';

import {AsyncReplicationInfo} from './AsyncReplicationInfo';
Expand Down Expand Up @@ -42,6 +43,7 @@ function Overview({type, path, database, databaseFullPath}: OverviewProps) {
[EPathType.EPathTypeDir]: undefined,
[EPathType.EPathTypeResourcePool]: undefined,
[EPathType.EPathTypeTable]: undefined,
[EPathType.EPathTypeSysView]: () => <SystemViewInfo data={data} />,
[EPathType.EPathTypeSubDomain]: undefined,
[EPathType.EPathTypeTableIndex]: () => <TableIndexInfo data={data} />,
[EPathType.EPathTypeExtSubDomain]: undefined,
Expand Down
33 changes: 33 additions & 0 deletions src/containers/Tenant/Info/SystemView/SystemView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type {YDBDefinitionListItem} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
import {YDBDefinitionList} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
import type {TEvDescribeSchemeResult} from '../../../../types/api/schema';
import {prepareSystemViewType} from '../../../../utils/schema';
import {getEntityName} from '../../utils';
import i18n from '../i18n';

const prepareSystemViewItems = (data: TEvDescribeSchemeResult): YDBDefinitionListItem[] => {
const systemViewType = data.PathDescription?.SysViewDescription?.Type;

return [
{
name: i18n('system-view_type'),
content: prepareSystemViewType(systemViewType),
},
];
};

interface SystemViewInfoProps {
data?: TEvDescribeSchemeResult;
}

export function SystemViewInfo({data}: SystemViewInfoProps) {
const entityName = getEntityName(data?.PathDescription);

if (!data) {
return <div className="error">{i18n('no-entity-data', {entityName})}</div>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know we use b() for classes usually

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with <Text color='danger'>

}

const items = prepareSystemViewItems(data);

return <YDBDefinitionList title={entityName} items={items} />;
}
6 changes: 5 additions & 1 deletion src/containers/Tenant/Info/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"external-objects.auth-method.none": "None",
"external-objects.auth-method.service-account": "Service Account",

"view.query-text": "Query Text"
"view.query-text": "Query Text",

"system-view_type": "System view type",

"no-entity-data": "No {{entityName}} data"
}
7 changes: 7 additions & 0 deletions src/containers/Tenant/ObjectSummary/ObjectSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
formatSecondsToHours,
} from '../../../utils/dataFormatters/dataFormatters';
import {useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
import {prepareSystemViewType} from '../../../utils/schema';
import {EntityTitle} from '../EntityTitle/EntityTitle';
import {SchemaViewer} from '../Schema/SchemaViewer/SchemaViewer';
import {useCurrentSchema} from '../TenantContext';
Expand Down Expand Up @@ -233,6 +234,12 @@ export function ObjectSummary({
content: PathDescription?.TablePartitions?.length,
},
],
[EPathType.EPathTypeSysView]: () => [
{
name: i18n('field_system-view-type'),
content: prepareSystemViewType(PathDescription?.SysViewDescription?.Type),
},
],
[EPathType.EPathTypeSubDomain]: getDatabaseOverview,
[EPathType.EPathTypeTableIndex]: undefined,
[EPathType.EPathTypeExtSubDomain]: getDatabaseOverview,
Expand Down
1 change: 1 addition & 0 deletions src/containers/Tenant/ObjectSummary/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"field_data-size": "Data size",
"field_row-count": "Row count",
"field_partitions": "Partitions count",
"field_system-view-type": "System view type",
"field_paths": "Paths",
"field_shards": "Shards",
"field_state": "State",
Expand Down
5 changes: 5 additions & 0 deletions src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
isColumnEntityType,
isExternalTableType,
isRowTableType,
isSystemViewType,
isViewType,
} from '../../utils/schema';

Expand All @@ -20,6 +21,7 @@ import {
getColumnTableColumns,
getExternalTableColumns,
getRowTableColumns,
getSystemViewColumns,
getViewColumns,
} from './columns';
import {prepareSchemaData, prepareViewSchema} from './prepareData';
Expand Down Expand Up @@ -82,6 +84,9 @@ export const SchemaViewer = ({
if (isViewType(type)) {
return getViewColumns(tableData);
}
if (isSystemViewType(type)) {
return getSystemViewColumns(tableData);
}
if (isExternalTableType(type)) {
return getExternalTableColumns(tableData);
}
Expand Down
3 changes: 3 additions & 0 deletions src/containers/Tenant/Schema/SchemaViewer/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ function normalizeColumns(columns: SchemaColumn[], data?: SchemaData[]) {
export function getViewColumns(data?: SchemaData[]): SchemaColumn[] {
return normalizeColumns([nameColumn, typeColumn], data);
}
export function getSystemViewColumns(data?: SchemaData[]): SchemaColumn[] {
return normalizeColumns([idColumn, nameColumn, typeColumn, notNullColumn], data);
}
export function getExternalTableColumns(data?: SchemaData[]): SchemaColumn[] {
return normalizeColumns([idColumn, nameColumn, typeColumn, notNullColumn], data);
}
Expand Down
9 changes: 7 additions & 2 deletions src/containers/Tenant/Schema/SchemaViewer/prepareData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import type {
} from '../../../../types/api/schema';
import {EColumnCodec} from '../../../../types/api/schema';
import type {Nullable} from '../../../../utils/typecheckers';
import {isColumnEntityType, isExternalTableType, isRowTableType} from '../../utils/schema';
import {
isColumnEntityType,
isExternalTableType,
isRowTableType,
isSystemViewType,
} from '../../utils/schema';

import type {SchemaData} from './types';

Expand Down Expand Up @@ -126,7 +131,7 @@ export function prepareSchemaData(
): SchemaData[] {
const {Table, ColumnTableDescription, ExternalTableDescription} = schema?.PathDescription || {};

if (isRowTableType(type)) {
if (isRowTableType(type) || isSystemViewType(type)) {
return prepareRowTableSchema(Table);
} else if (isColumnEntityType(type)) {
return prepareColumnTableSchema(ColumnTableDescription);
Expand Down
7 changes: 7 additions & 0 deletions src/containers/Tenant/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const pathTypeToNodeType: Record<EPathType, NavigationTreeNodeType | undefined>
[EPathType.EPathTypeColumnStore]: 'directory',

[EPathType.EPathTypeTable]: 'table',
[EPathType.EPathTypeSysView]: 'system_table',

[EPathType.EPathTypeTableIndex]: 'index',

Expand Down Expand Up @@ -76,6 +77,7 @@ const pathTypeToEntityName: Record<EPathType, string | undefined> = {

[EPathType.EPathTypeDir]: 'Directory',
[EPathType.EPathTypeTable]: 'Table',
[EPathType.EPathTypeSysView]: 'System view',
[EPathType.EPathTypeTableIndex]: 'Secondary Index',
[EPathType.EPathTypeColumnStore]: 'Tablestore',
[EPathType.EPathTypeColumnTable]: 'Column-oriented table',
Expand Down Expand Up @@ -115,6 +117,7 @@ export const mapDatabaseTypeToDBName = (type?: ETenantType) => type && databaseT
const pathTypeToIsTable: Record<EPathType, boolean> = {
[EPathType.EPathTypeTable]: true,
[EPathType.EPathTypeColumnTable]: true,
[EPathType.EPathTypeSysView]: true,

[EPathType.EPathTypeExternalTable]: true,

Expand Down Expand Up @@ -160,6 +163,7 @@ const pathTypeToIsColumn: Record<EPathType, boolean> = {
[EPathType.EPathTypeInvalid]: false,
[EPathType.EPathTypeDir]: false,
[EPathType.EPathTypeTable]: false,
[EPathType.EPathTypeSysView]: false,
[EPathType.EPathTypeSubDomain]: false,
[EPathType.EPathTypeTableIndex]: false,
[EPathType.EPathTypeExtSubDomain]: false,
Expand Down Expand Up @@ -189,6 +193,7 @@ const pathTypeToIsDatabase: Record<EPathType, boolean> = {
[EPathType.EPathTypeColumnStore]: false,
[EPathType.EPathTypeColumnTable]: false,
[EPathType.EPathTypeTable]: false,
[EPathType.EPathTypeSysView]: false,
[EPathType.EPathTypeTableIndex]: false,
[EPathType.EPathTypeCdcStream]: false,
[EPathType.EPathTypePersQueueGroup]: false,
Expand Down Expand Up @@ -240,6 +245,7 @@ const pathTypeToChildless: Record<EPathType, boolean> = {
[EPathType.EPathTypeColumnTable]: false,
[EPathType.EPathTypeDir]: false,
[EPathType.EPathTypeTable]: false,
[EPathType.EPathTypeSysView]: false,
[EPathType.EPathTypeSubDomain]: false,
[EPathType.EPathTypeTableIndex]: false,
[EPathType.EPathTypeExtSubDomain]: false,
Expand All @@ -253,3 +259,4 @@ export const isChildlessPathType = (type?: EPathType, subType?: EPathSubType) =>
export const isExternalTableType = (type?: EPathType) => type === EPathType.EPathTypeExternalTable;
export const isRowTableType = (type?: EPathType) => type === EPathType.EPathTypeTable;
export const isViewType = (type?: EPathType) => type === EPathType.EPathTypeView;
export const isSystemViewType = (type?: EPathType) => type === EPathType.EPathTypeSysView;
3 changes: 3 additions & 0 deletions src/types/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {TExternalDataSourceDescription} from './externalDataSource';
import type {TExternalTableDescription} from './externalTable';
import type {TPersQueueGroupDescription} from './persQueueGroup';
import type {TReplicationDescription} from './replication';
import type {TSysViewDescription} from './sysView';
import type {TTableDescription, TTableStats} from './table';
import type {TIndexDescription} from './tableIndex';
import type {TViewDescription} from './view';
Expand Down Expand Up @@ -86,6 +87,7 @@ export interface TPathDescription {
ExternalDataSourceDescription?: TExternalDataSourceDescription;

ViewDescription?: TViewDescription;
SysViewDescription?: TSysViewDescription;

ReplicationDescription?: TReplicationDescription;
}
Expand Down Expand Up @@ -283,6 +285,7 @@ export enum EPathType {
EPathTypeTable = 'EPathTypeTable',
EPathTypePersQueueGroup = 'EPathTypePersQueueGroup',
EPathTypeSubDomain = 'EPathTypeSubDomain',
EPathTypeSysView = 'EPathTypeSysView',

EPathTypeTableIndex = 'EPathTypeTableIndex',
EPathTypeExtSubDomain = 'EPathTypeExtSubDomain',
Expand Down
44 changes: 44 additions & 0 deletions src/types/api/schema/sysView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type {TPathID} from './shared';

export interface TSysViewDescription {
Name?: string;
Type?: ESysViewType;
SourceObject?: TPathID;
}

export type ESysViewType =
| 'EPartitionStats'
| 'ENodes'
| 'ETopQueriesByDurationOneMinute'
| 'ETopQueriesByDurationOneHour'
| 'ETopQueriesByReadBytesOneMinute'
| 'ETopQueriesByReadBytesOneHour'
| 'ETopQueriesByCpuTimeOneMinute'
| 'ETopQueriesByCpuTimeOneHour'
| 'ETopQueriesByRequestUnitsOneMinute'
| 'ETopQueriesByRequestUnitsOneHour'
| 'EQuerySessions'
| 'EPDisks'
| 'EVSlots'
| 'EGroups'
| 'EStoragePools'
| 'EStorageStats'
| 'ETablets'
| 'EQueryMetricsOneMinute'
| 'ETopPartitionsByCpuOneMinute'
| 'ETopPartitionsByCpuOneHour'
| 'ETopPartitionsByTliOneMinute'
| 'ETopPartitionsByTliOneHour'
| 'EResourcePoolClassifiers'
| 'EResourcePools'
| 'EAuthUsers'
| 'EAuthGroups'
| 'EAuthGroupMembers'
| 'EAuthOwners'
| 'EAuthPermissions'
| 'EAuthEffectivePermissions'
| 'EPgTables'
| 'EInformationSchemaTables'
| 'EPgClass'
| 'EShowCreate'
| 'ECompileCacheQueries';
11 changes: 11 additions & 0 deletions src/utils/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type {ESysViewType} from '../types/api/schema/sysView';

export function prepareSystemViewType(type?: ESysViewType) {
if (!type) {
return undefined;
}
if (type.startsWith('E')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks fragile - would be great if you left some comment what and why is 'E'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment

return type.slice(1);
}
return type;
}
Loading