Skip to content

Commit

Permalink
Merge branch 'main' into 1042-tablet
Browse files Browse the repository at this point in the history
  • Loading branch information
Raubzeug authored Aug 19, 2024
2 parents 1395cd0 + 5b80904 commit f452a08
Show file tree
Hide file tree
Showing 28 changed files with 205 additions and 170 deletions.
1 change: 0 additions & 1 deletion .husky/commit-msg

This file was deleted.

13 changes: 12 additions & 1 deletion src/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"selector": "ImportDeclaration[source.value='axios'] :matches(ImportSpecifier[imported.name='isAxiosError'])",
"message": "Please use isAxiosError from utils/response instead of axios",
},
],
],
"no-restricted-imports": [
"error",
{
"patterns": [
{
"group": [".*/**/lib"],
"message": "Please use direct imports instead",
},
],
},
],
},
}
3 changes: 2 additions & 1 deletion src/components/ElapsedTime/ElapsedTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import React from 'react';
import {duration} from '@gravity-ui/date-utils';
import {Label} from '@gravity-ui/uikit';

import {HOUR_IN_SECONDS, SECOND_IN_MS, cn} from '../../lib';
import {cn} from '../../utils/cn';
import {HOUR_IN_SECONDS, SECOND_IN_MS} from '../../utils/constants';

const b = cn('ydb-query-elapsed-time');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Text} from '@gravity-ui/uikit';
import omit from 'lodash/omit';

import {toFormattedSize} from '../../../../../components/FormattedBytes/utils';
import type {InfoViewerItem} from '../../../../../components/InfoViewer';
import {formatObject} from '../../../../../components/InfoViewer';
import {
Expand All @@ -17,8 +18,10 @@ import type {
TTTLSettings,
} from '../../../../../types/api/schema';
import {EPathType} from '../../../../../types/api/schema';
import {valueIsDefined} from '../../../../../utils';
import {formatBytes, formatNumber} from '../../../../../utils/dataFormatters/dataFormatters';
import {formatDurationToShortTimeFormat} from '../../../../../utils/timeParsers';
import {isNumeric} from '../../../../../utils/utils';

import i18n from './i18n';

Expand Down Expand Up @@ -126,10 +129,12 @@ const prepareTableGeneralInfo = (PartitionConfig: TPartitionConfig, TTLSettings?
}
}

generalTableInfo.push({
label: i18n('label.bloom-filter'),
value: EnableFilterByKey ? i18n('enabled') : i18n('disabled'),
});
if (valueIsDefined(EnableFilterByKey)) {
generalTableInfo.push({
label: i18n('label.bloom-filter'),
value: EnableFilterByKey ? i18n('enabled') : i18n('disabled'),
});
}

return generalTableInfo;
};
Expand All @@ -154,6 +159,7 @@ export const prepareTableInfo = (data?: TEvDescribeSchemeResult, type?: EPathTyp
RowCount,
DataSize,
IndexSize,
ByKeyFilterSize,

LastAccessTime,
LastUpdateTime,
Expand Down Expand Up @@ -187,13 +193,22 @@ export const prepareTableInfo = (data?: TEvDescribeSchemeResult, type?: EPathTyp
}
}

const generalStats = formatObject(formatTableStatsItem, {
PartCount,
RowCount,
DataSize,
IndexSize,
});

if (
isNumeric(ByKeyFilterSize) &&
(PartitionConfig.EnableFilterByKey || Number(ByKeyFilterSize) > 0)
) {
generalStats.push({label: 'BloomFilterSize', value: toFormattedSize(ByKeyFilterSize)});
}

const tableStatsInfo = [
formatObject(formatTableStatsItem, {
PartCount,
RowCount,
DataSize,
IndexSize,
}),
generalStats,
formatObject(formatTableStatsItem, {
LastAccessTime,
LastUpdateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {toExponential} from '../../../../../../utils/utils';
import {MetricsCell} from './MetricsCell';
import {OperationCell} from './OperationCell';
import type {ExtendedSimplifiesPlanItem} from './types';
import {block, getExtendedTreeNodes, getTreeNodesCoordinates} from './utils';
import {block, getExtendedTreeNodes} from './utils';

import './SimplifiedPlan.scss';

Expand Down Expand Up @@ -100,10 +100,7 @@ interface SimplifiedPlanProps {

export function SimplifiedPlan({plan}: SimplifiedPlanProps) {
const planWithLinesInfo = React.useMemo(() => getExtendedTreeNodes(plan), [plan]);
const [expanded, setExpanded] = React.useState<ExpandedState>(() => {
const coordinates = getTreeNodesCoordinates(plan);
return Object.fromEntries(coordinates.map((id) => [id, true]));
});
const [expanded, setExpanded] = React.useState<ExpandedState>(true);

const table = useTable({
columns,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,86 +1,6 @@
import type {SimplifiedPlanItem} from '../../../../../../../store/reducers/explainQuery/types';
import type {ExtendedSimplifiesPlanItem} from '../types';
import {getExtendedTreeNodes, getTreeNodesCoordinates} from '../utils';

describe('getTreeNodesCoordinates', () => {
test('should handle empty input', () => {
const result = getTreeNodesCoordinates();
expect(result).toEqual([]);
});

test('should handle single node without children', () => {
const items: SimplifiedPlanItem[] = [
{
name: 'TestNode',
operationParams: {},
children: [],
},
];

const expected = ['0'];

const result = getTreeNodesCoordinates(items);
expect(result).toEqual(expected);
});

test('should handle nested nodes', () => {
const items: SimplifiedPlanItem[] = [
{
name: 'RootNode',
operationParams: {},
children: [
{
name: 'ChildNode1',
operationParams: {},
children: [],
},
{
name: 'ChildNode2',
operationParams: {},
children: [
{
name: 'GrandChildNode',
operationParams: {},
children: [],
},
],
},
],
},
];

const expected = ['0', '0.0', '0.1', '0.1.0'];

const result = getTreeNodesCoordinates(items);
expect(result).toEqual(expected);
});

test('should handle multiple root nodes', () => {
const items: SimplifiedPlanItem[] = [
{
name: 'RootNode1',
operationParams: {},
children: [],
},
{
name: 'RootNode2',
operationParams: {},
children: [
{
name: 'ChildNode',
operationParams: {},
children: [],
},
],
},
];

const expected = ['0', '1', '1.0'];

const result = getTreeNodesCoordinates(items);
expect(result).toEqual(expected);
});
});
import {getExtendedTreeNodes} from '../utils';

describe('getExtendedTreeNodes', () => {
test('should handle empty input', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,6 @@ import type {ExtendedSimplifiesPlanItem} from './types';

export const block = cn('ydb-query-explain-simplified-plan');

export function getTreeNodesCoordinates(items?: SimplifiedPlanItem[], prefix = '') {
const result: string[] = [];
const stack: {items?: SimplifiedPlanItem[]; prefix: string}[] = [];

if (items) {
stack.push({items, prefix});
}

while (stack.length > 0) {
const {items, prefix} = stack.pop()!;

items?.forEach((item, index) => {
let newPrefix = `${prefix}.${index}`;
if (!prefix) {
newPrefix = String(index);
}
result.push(newPrefix);

if (item.children) {
stack.push({items: item.children, prefix: newPrefix});
}
});
}

return result;
}

export function getExtendedTreeNodes(
items?: SimplifiedPlanItem[],
prefix = '',
Expand Down
5 changes: 2 additions & 3 deletions src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {MonacoEditor} from '../../../../components/MonacoEditor/MonacoEditor';
import SplitPane from '../../../../components/SplitPane';
import type {RootState} from '../../../../store';
import {cancelQueryApi} from '../../../../store/reducers/cancelQuery';
import {useTracingLevelOptionAvailable} from '../../../../store/reducers/capabilities/hooks';
import {
executeQueryApi,
goToNextQuery,
Expand All @@ -29,7 +30,6 @@ import {cn} from '../../../../utils/cn';
import {
DEFAULT_IS_QUERY_RESULT_COLLAPSED,
DEFAULT_SIZE_RESULT_PANE_KEY,
ENABLE_TRACING_LEVEL_KEY,
LAST_USED_QUERY_ACTION_KEY,
QUERY_USE_MULTI_SCHEMA_KEY,
} from '../../../../utils/constants';
Expand Down Expand Up @@ -103,7 +103,7 @@ function QueryEditor(props: QueryEditorProps) {
const [resultType, setResultType] = React.useState<ValueOf<typeof RESULT_TYPES>>();
const [isResultLoaded, setIsResultLoaded] = React.useState(false);
const [querySettings] = useQueryExecutionSettings();
const [enableTracingLevel] = useSetting<boolean>(ENABLE_TRACING_LEVEL_KEY);
const enableTracingLevel = useTracingLevelOptionAvailable();
const [lastQueryExecutionSettings, setLastQueryExecutionSettings] =
useLastQueryExecutionSettings();
const {resetBanner} = useChangedQuerySettings();
Expand Down Expand Up @@ -187,7 +187,6 @@ function QueryEditor(props: QueryEditorProps) {

const handleSettingsClick = () => {
props.setQueryAction('settings');
props.setShowPreview(false);
};

const handleGetExplainQueryClick = useEventHandler(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {Dialog, Link as ExternalLink, Flex, TextInput} from '@gravity-ui/uikit';
import {Controller, useForm} from 'react-hook-form';

import {ENABLE_TRACING_LEVEL_KEY} from '../../../../lib';
import {useTracingLevelOptionAvailable} from '../../../../store/reducers/capabilities/hooks';
import {
selectQueryAction,
setQueryAction,
Expand All @@ -12,7 +12,6 @@ import type {QuerySettings} from '../../../../types/store/query';
import {cn} from '../../../../utils/cn';
import {
useQueryExecutionSettings,
useSetting,
useTypedDispatch,
useTypedSelector,
} from '../../../../utils/hooks';
Expand Down Expand Up @@ -71,7 +70,7 @@ function QuerySettingsForm({initialValues, onSubmit, onClose}: QuerySettingsForm
defaultValues: initialValues,
});

const [enableTracingLevel] = useSetting<boolean>(ENABLE_TRACING_LEVEL_KEY);
const enableTracingLevel = useTracingLevelOptionAvailable();

return (
<form onSubmit={handleSubmit(onSubmit)}>
Expand Down
3 changes: 2 additions & 1 deletion src/containers/Tenant/Query/utils/useSavedQueries.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {SAVED_QUERIES_KEY, useSetting, useTypedSelector} from '../../../../lib';
import {selectSavedQueriesFilter} from '../../../../store/reducers/queryActions/queryActions';
import type {SavedQuery} from '../../../../types/store/query';
import {SAVED_QUERIES_KEY} from '../../../../utils/constants';
import {useSetting, useTypedSelector} from '../../../../utils/hooks';

export function useSavedQueries() {
const [savedQueries] = useSetting<SavedQuery[]>(SAVED_QUERIES_KEY, []);
Expand Down
11 changes: 6 additions & 5 deletions src/containers/Tenant/utils/queryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ WITH (
AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048,
AUTO_PARTITIONING_BY_LOAD = ENABLED,
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4,
AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024,
AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024
-- uncomment to create a table with predefined partitions
-- UNIFORM_PARTITIONS = 4, -- The number of partitions for uniform initial table partitioning.
-- , UNIFORM_PARTITIONS = 4 -- The number of partitions for uniform initial table partitioning.
-- The primary key's first column must have type Uint64 or Uint32.
-- A created table is immediately divided into the specified number of partitions
-- uncomment to launch read only replicas in every AZ
-- READ_REPLICAS_SETTINGS = 'PER_AZ:1', -- Enable read replicas for stale read, launch one replica in every availability zone
-- , READ_REPLICAS_SETTINGS = 'PER_AZ:1' -- Enable read replicas for stale read, launch one replica in every availability zone
-- uncomment to enable ttl
-- TTL = Interval("PT1H") ON expire_at, -- Enable background deletion of expired rows https://ydb.tech/en/docs/concepts/ttl
KEY_BLOOM_FILTER = ENABLED -- With a Bloom filter, you can more efficiently determine
-- , TTL = Interval("PT1H") ON expire_at -- Enable background deletion of expired rows https://ydb.tech/en/docs/concepts/ttl
-- uncomment to create a table with a bloom filter
-- , KEY_BLOOM_FILTER = ENABLED -- With a Bloom filter, you can more efficiently determine
-- if some keys are missing in a table when making multiple single queries by the primary key.
)`;
};
Expand Down
3 changes: 0 additions & 3 deletions src/containers/UserSettings/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

"settings.showDomainDatabase.title": "Show domain database",

"settings.enableTracingLevel.title": "Enable tracing level select",
"settings.enableTracingLevel.description": "Caution: Enabling this setting may break running of queries",

"settings.queryUseMultiSchema.title": "Allow queries with multiple result sets",
"settings.queryUseMultiSchema.description": "Use 'multi' schema for queries. It enables queries with multiple result sets. It returns nothing on versions 23-3 and older",

Expand Down
9 changes: 1 addition & 8 deletions src/containers/UserSettings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
AUTOCOMPLETE_ON_ENTER,
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
ENABLE_AUTOCOMPLETE,
ENABLE_TRACING_LEVEL_KEY,
INVERTED_DISKS_KEY,
LANGUAGE_KEY,
QUERY_USE_MULTI_SCHEMA_KEY,
Expand Down Expand Up @@ -113,12 +112,6 @@ export const showDomainDatabase: SettingProps = {
title: i18n('settings.showDomainDatabase.title'),
};

export const enableTracingLevel: SettingProps = {
settingKey: ENABLE_TRACING_LEVEL_KEY,
title: i18n('settings.enableTracingLevel.title'),
description: i18n('settings.enableTracingLevel.description'),
};

export const queryUseMultiSchemaSetting: SettingProps = {
settingKey: QUERY_USE_MULTI_SCHEMA_KEY,
title: i18n('settings.queryUseMultiSchema.title'),
Expand Down Expand Up @@ -167,7 +160,7 @@ export const experimentsSection: SettingsSection = {
export const devSettingsSection: SettingsSection = {
id: 'devSettingsSection',
title: i18n('section.dev-setting'),
settings: [enableAutocompleteSetting, autocompleteOnEnterSetting, enableTracingLevel],
settings: [enableAutocompleteSetting, autocompleteOnEnterSetting],
};

export const aboutSettingsSection: SettingsSection = {
Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */
/* eslint-disable import/order */
import ReactDOM from 'react-dom/client';

Expand Down
2 changes: 0 additions & 2 deletions src/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
DEFAULT_QUERY_SETTINGS,
ENABLE_AUTOCOMPLETE,
ENABLE_TRACING_LEVEL_KEY,
INVERTED_DISKS_KEY,
IS_HOTKEYS_HELP_HIDDEN_KEY,
LANGUAGE_KEY,
Expand Down Expand Up @@ -48,7 +47,6 @@ export const DEFAULT_USER_SETTINGS = {
[AUTOCOMPLETE_ON_ENTER]: true,
[IS_HOTKEYS_HELP_HIDDEN_KEY]: false,
[AUTO_REFRESH_INTERVAL]: 0,
[ENABLE_TRACING_LEVEL_KEY]: false,
[SHOW_DOMAIN_DATABASE_KEY]: false,
[LAST_QUERY_EXECUTION_SETTINGS_KEY]: undefined,
[QUERY_SETTINGS_BANNER_LAST_CLOSED_KEY]: undefined,
Expand Down
Loading

0 comments on commit f452a08

Please sign in to comment.