From 59f2ae315ee9b7c80ce803226544b3db2201cff5 Mon Sep 17 00:00:00 2001 From: mufazalov Date: Mon, 3 Mar 2025 11:48:10 +0300 Subject: [PATCH 1/2] feat: add QUERY_TECHNICAL_MARK to all UI queries --- .../TenantStorage/TenantStorage.tsx | 2 +- .../TenantStorage/TopTables.tsx | 6 +-- src/store/reducers/cluster/utils.ts | 7 +-- .../executeTopQueries/executeTopQueries.ts | 53 +++++++++++-------- src/store/reducers/executeTopQueries/utils.ts | 8 +-- .../reducers/shardsWorkload/shardsWorkload.ts | 29 +++++----- .../executeTopTables/executeTopTables.ts | 18 +++---- .../topShards/tenantOverviewTopShards.ts | 13 ++--- src/utils/constants.ts | 2 + 9 files changed, 76 insertions(+), 62 deletions(-) diff --git a/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TenantStorage.tsx b/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TenantStorage.tsx index 4c9e9db802..3419c76e84 100644 --- a/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TenantStorage.tsx +++ b/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TenantStorage.tsx @@ -68,7 +68,7 @@ export function TenantStorage({tenantName, metrics}: TenantStorageProps) { - + ); diff --git a/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.tsx b/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.tsx index 52fe25942c..8f4ed26f92 100644 --- a/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.tsx +++ b/src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.tsx @@ -16,18 +16,18 @@ import i18n from '../i18n'; import '../TenantOverview.scss'; interface TopTablesProps { - path: string; + database: string; } const TOP_TABLES_COLUMNS_WIDTH_LS_KEY = 'topTablesTableColumnsWidth'; -export function TopTables({path}: TopTablesProps) { +export function TopTables({database}: TopTablesProps) { const location = useLocation(); const [autoRefreshInterval] = useAutoRefreshInterval(); const {currentData, error, isFetching} = topTablesApi.useGetTopTablesQuery( - {path}, + {database}, {pollingInterval: autoRefreshInterval}, ); const loading = isFetching && currentData === undefined; diff --git a/src/store/reducers/cluster/utils.ts b/src/store/reducers/cluster/utils.ts index 1664a3cf1b..a749200ec1 100644 --- a/src/store/reducers/cluster/utils.ts +++ b/src/store/reducers/cluster/utils.ts @@ -1,11 +1,12 @@ import type {TClusterInfoV2, TStorageStats} from '../../../types/api/cluster'; import type {ExecuteQueryResponse, KeyValueRow} from '../../../types/api/query'; +import {QUERY_TECHNICAL_MARK} from '../../../utils/constants'; import {parseQueryAPIResponse} from '../../../utils/query'; import type {ClusterGroupsStats} from './types'; export const createSelectClusterGroupsQuery = (clusterRoot: string) => { - return ` + return `${QUERY_TECHNICAL_MARK} SELECT PDiskFilter, ErasureSpecies, @@ -13,8 +14,8 @@ SELECT CurrentAllocatedSize, CurrentGroupsCreated, AvailableGroupsToCreate - FROM \`${clusterRoot}/.sys/ds_storage_stats\` - ORDER BY CurrentGroupsCreated DESC; +FROM \`${clusterRoot}/.sys/ds_storage_stats\` +ORDER BY CurrentGroupsCreated DESC; `; }; diff --git a/src/store/reducers/executeTopQueries/executeTopQueries.ts b/src/store/reducers/executeTopQueries/executeTopQueries.ts index 7e99fae7a2..1701eb8140 100644 --- a/src/store/reducers/executeTopQueries/executeTopQueries.ts +++ b/src/store/reducers/executeTopQueries/executeTopQueries.ts @@ -3,6 +3,7 @@ import type {SortOrder} from '@gravity-ui/react-data-table'; import {createSlice} from '@reduxjs/toolkit'; import type {PayloadAction} from '@reduxjs/toolkit'; +import {QUERY_TECHNICAL_MARK} from '../../../utils/constants'; import {prepareOrderByFromTableSort} from '../../../utils/hooks/useTableSort'; import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../utils/query'; import {api} from '../api'; @@ -12,8 +13,6 @@ import {getFiltersConditions} from './utils'; const initialState: TopQueriesFilters = {}; -const QUERY_TECHNICAL_MARK = '/*UI-QUERY-EXCLUDE*/'; - const slice = createSlice({ name: 'executeTopQueries', initialState, @@ -27,13 +26,13 @@ const slice = createSlice({ export const {setTopQueriesFilters} = slice.actions; export default slice.reducer; -const getQueryText = (path: string, filters?: TopQueriesFilters, sortOrder?: SortOrder[]) => { - const filterConditions = getFiltersConditions(path, filters); +const getQueryText = (database: string, filters?: TopQueriesFilters, sortOrder?: SortOrder[]) => { + const filterConditions = getFiltersConditions(database, filters); const orderBy = prepareOrderByFromTableSort(sortOrder); - return ` -SELECT ${QUERY_TECHNICAL_MARK} + return `${QUERY_TECHNICAL_MARK} +SELECT CPUTime as CPUTimeUs, QueryText, IntervalEnd, @@ -42,13 +41,36 @@ SELECT ${QUERY_TECHNICAL_MARK} ReadBytes, UserSID, Duration -FROM \`${path}/.sys/top_queries_by_cpu_time_one_hour\` +FROM \`${database}/.sys/top_queries_by_cpu_time_one_hour\` WHERE ${filterConditions || 'true'} AND QueryText NOT LIKE '%${QUERY_TECHNICAL_MARK}%' ${orderBy} LIMIT 100 `; }; +function getRunningQueriesText( + database: string, + filters?: TopQueriesFilters, + sortOrder?: SortOrder[], +) { + const filterConditions = filters?.text + ? `Query ILIKE '%${filters.text}%' OR UserSID ILIKE '%${filters.text}%'` + : ''; + + const orderBy = prepareOrderByFromTableSort(sortOrder); + + return `${QUERY_TECHNICAL_MARK} +SELECT + UserSID, + QueryStartAt, + Query as QueryText, + ApplicationName +FROM \`${database}/.sys/query_sessions\` +WHERE ${filterConditions || 'true'} AND Query NOT LIKE '%${QUERY_TECHNICAL_MARK}%' +${orderBy} +LIMIT 100`; +} + interface TopQueriesRequestParams { database: string; filters?: TopQueriesFilters; @@ -102,24 +124,9 @@ export const topQueriesApi = api.injectEndpoints({ getRunningQueries: build.query({ queryFn: async ({database, filters, sortOrder}: TopQueriesRequestParams, {signal}) => { try { - const filterConditions = filters?.text - ? `Query ILIKE '%${filters.text}%' OR UserSID ILIKE '%${filters.text}%'` - : ''; - - const orderBy = prepareOrderByFromTableSort(sortOrder); - - const queryText = `SELECT ${QUERY_TECHNICAL_MARK} - UserSID, QueryStartAt, Query as QueryText, ApplicationName - FROM - \`.sys/query_sessions\` - WHERE - ${filterConditions || 'true'} AND Query NOT LIKE '%${QUERY_TECHNICAL_MARK}%' - ${orderBy} - LIMIT 100`; - const response = await window.api.viewer.sendQuery( { - query: queryText, + query: getRunningQueriesText(database, filters, sortOrder), database, action: 'execute-scan', }, diff --git a/src/store/reducers/executeTopQueries/utils.ts b/src/store/reducers/executeTopQueries/utils.ts index f1a7a893c5..778690b804 100644 --- a/src/store/reducers/executeTopQueries/utils.ts +++ b/src/store/reducers/executeTopQueries/utils.ts @@ -5,13 +5,13 @@ import type {TopQueriesFilters} from './types'; const endTimeColumn = 'EndTime'; const intervalEndColumn = 'IntervalEnd'; -const getMaxIntervalSubquery = (path: string) => `( +const getMaxIntervalSubquery = (database: string) => `( SELECT MAX(${intervalEndColumn}) - FROM \`${path}/.sys/top_queries_by_cpu_time_one_hour\` + FROM \`${database}/.sys/top_queries_by_cpu_time_one_hour\` )`; -export function getFiltersConditions(path: string, filters?: TopQueriesFilters) { +export function getFiltersConditions(database: string, filters?: TopQueriesFilters) { const conditions: string[] = []; const to = dateTimeParse(Number(filters?.to) || filters?.to)?.valueOf(); const from = dateTimeParse(Number(filters?.from) || filters?.from)?.valueOf(); @@ -33,7 +33,7 @@ export function getFiltersConditions(path: string, filters?: TopQueriesFilters) // If there is no filters, return queries, that were executed in the last hour if (!from && !to) { - conditions.push(`${intervalEndColumn} IN ${getMaxIntervalSubquery(path)}`); + conditions.push(`${intervalEndColumn} IN ${getMaxIntervalSubquery(database)}`); } if (filters?.text) { diff --git a/src/store/reducers/shardsWorkload/shardsWorkload.ts b/src/store/reducers/shardsWorkload/shardsWorkload.ts index a2da79903b..4f7d83de06 100644 --- a/src/store/reducers/shardsWorkload/shardsWorkload.ts +++ b/src/store/reducers/shardsWorkload/shardsWorkload.ts @@ -3,6 +3,7 @@ import type {SortOrder} from '@gravity-ui/react-data-table'; import {createSlice} from '@reduxjs/toolkit'; import type {PayloadAction} from '@reduxjs/toolkit'; +import {QUERY_TECHNICAL_MARK} from '../../../utils/constants'; import {prepareOrderByFromTableSort} from '../../../utils/hooks/useTableSort'; import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../utils/query'; import {api} from '../api'; @@ -37,12 +38,12 @@ function getFiltersConditions(filters?: ShardsWorkloadFilters) { function createShardQueryHistorical( path: string, + database: string, filters?: ShardsWorkloadFilters, sortOrder?: SortOrder[], - tenantName?: string, ) { - const pathSelect = tenantName - ? `CAST(SUBSTRING(CAST(Path AS String), ${tenantName.length}) AS Utf8) AS Path` + const pathSelect = database + ? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path` : 'Path'; let where = `Path='${path}' OR Path LIKE '${path}/%'`; @@ -54,7 +55,8 @@ function createShardQueryHistorical( const orderBy = prepareOrderByFromTableSort(sortOrder); - return `SELECT + return `${QUERY_TECHNICAL_MARK} +SELECT ${pathSelect}, TabletId, CPUCores, @@ -63,27 +65,28 @@ function createShardQueryHistorical( PeakTime, InFlightTxCount, IntervalEnd -FROM \`.sys/top_partitions_one_hour\` +FROM \`${database}/.sys/top_partitions_one_hour\` WHERE ${where} ${orderBy} LIMIT 20`; } -function createShardQueryImmediate(path: string, sortOrder?: SortOrder[], tenantName?: string) { - const pathSelect = tenantName - ? `CAST(SUBSTRING(CAST(Path AS String), ${tenantName.length}) AS Utf8) AS Path` +function createShardQueryImmediate(path: string, database: string, sortOrder?: SortOrder[]) { + const pathSelect = database + ? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path` : 'Path'; const orderBy = prepareOrderByFromTableSort(sortOrder); - return `SELECT + return `${QUERY_TECHNICAL_MARK} +SELECT ${pathSelect}, TabletId, CPUCores, DataSize, NodeId, InFlightTxCount -FROM \`.sys/partition_stats\` +FROM \`${database}/.sys/partition_stats\` WHERE Path='${path}' OR Path LIKE '${path}/%' @@ -110,7 +113,7 @@ export const {setShardsQueryFilters} = slice.actions; export default slice.reducer; interface SendShardQueryParams { - database?: string; + database: string; path?: string; sortOrder?: SortOrder[]; filters?: ShardsWorkloadFilters; @@ -128,12 +131,12 @@ export const shardApi = api.injectEndpoints({ { query: filters?.mode === EShardsWorkloadMode.Immediate - ? createShardQueryImmediate(path, sortOrder, database) + ? createShardQueryImmediate(path, database, sortOrder) : createShardQueryHistorical( path, + database, filters, sortOrder, - database, ), database, action: queryAction, diff --git a/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts b/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts index 068140da4e..28686bb268 100644 --- a/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts +++ b/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts @@ -1,27 +1,27 @@ -import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants'; +import {QUERY_TECHNICAL_MARK, TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants'; import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../../utils/query'; import {api} from '../../api'; -const getQueryText = (path: string) => { - return ` +const getQueryText = (database: string) => { + return `${QUERY_TECHNICAL_MARK} SELECT Path, SUM(DataSize) as Size -FROM \`${path}/.sys/partition_stats\` +FROM \`${database}/.sys/partition_stats\` GROUP BY Path - ORDER BY Size DESC - LIMIT ${TENANT_OVERVIEW_TABLES_LIMIT} +ORDER BY Size DESC +LIMIT ${TENANT_OVERVIEW_TABLES_LIMIT} `; }; export const topTablesApi = api.injectEndpoints({ endpoints: (builder) => ({ getTopTables: builder.query({ - queryFn: async ({path}: {path: string}, {signal}) => { + queryFn: async ({database}: {database: string}, {signal}) => { try { const response = await window.api.viewer.sendQuery( { - query: getQueryText(path), - database: path, + query: getQueryText(database), + database, action: 'execute-scan', }, {signal, withRetries: true}, diff --git a/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts b/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts index c379610669..f09f20aebe 100644 --- a/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts +++ b/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts @@ -1,17 +1,18 @@ -import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants'; +import {QUERY_TECHNICAL_MARK, TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants'; import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../../utils/query'; import {api} from '../../api'; -function createShardQuery(path: string, tenantName?: string) { - const pathSelect = tenantName - ? `CAST(SUBSTRING(CAST(Path AS String), ${tenantName.length}) AS Utf8) AS Path` +function createShardQuery(path: string, database: string) { + const pathSelect = database + ? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path` : 'Path'; - return `SELECT + return `${QUERY_TECHNICAL_MARK} +SELECT ${pathSelect}, TabletId, CPUCores, -FROM \`.sys/partition_stats\` +FROM \`${database}/.sys/partition_stats\` WHERE Path='${path}' OR Path LIKE '${path}/%' diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 98957ef76c..17aeba8e8f 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -52,6 +52,8 @@ export const TENANT_OVERVIEW_TABLES_LIMIT = 5; export const EMPTY_DATA_PLACEHOLDER = '—'; +export const QUERY_TECHNICAL_MARK = '/*UI-QUERY-EXCLUDE*/'; + // ==== Titles ==== export const DEVELOPER_UI_TITLE = 'Developer UI'; export const CLUSTER_DEFAULT_TITLE = 'Cluster'; From ed81743e80fccb9d6233f0d08e28221bd1930758 Mon Sep 17 00:00:00 2001 From: mufazalov Date: Mon, 10 Mar 2025 12:40:45 +0300 Subject: [PATCH 2/2] fix: use relative paths, remove unused conditions --- src/store/reducers/cluster/cluster.ts | 2 +- src/store/reducers/cluster/utils.ts | 4 ++-- .../executeTopQueries/executeTopQueries.ts | 18 +++++++----------- src/store/reducers/executeTopQueries/utils.ts | 8 ++++---- .../reducers/shardsWorkload/shardsWorkload.ts | 12 ++++-------- .../executeTopTables/executeTopTables.ts | 6 +++--- .../topShards/tenantOverviewTopShards.ts | 7 ++----- 7 files changed, 23 insertions(+), 34 deletions(-) diff --git a/src/store/reducers/cluster/cluster.ts b/src/store/reducers/cluster/cluster.ts index 2768766f93..753d5d7dc6 100644 --- a/src/store/reducers/cluster/cluster.ts +++ b/src/store/reducers/cluster/cluster.ts @@ -87,7 +87,7 @@ export const clusterApi = api.injectEndpoints({ } try { - const query = createSelectClusterGroupsQuery(clusterRoot); + const query = createSelectClusterGroupsQuery(); // Normally query request should be fulfilled within 300-400ms even on very big clusters // Table with stats is supposed to be very small (less than 10 rows) diff --git a/src/store/reducers/cluster/utils.ts b/src/store/reducers/cluster/utils.ts index a749200ec1..2f69ddad24 100644 --- a/src/store/reducers/cluster/utils.ts +++ b/src/store/reducers/cluster/utils.ts @@ -5,7 +5,7 @@ import {parseQueryAPIResponse} from '../../../utils/query'; import type {ClusterGroupsStats} from './types'; -export const createSelectClusterGroupsQuery = (clusterRoot: string) => { +export const createSelectClusterGroupsQuery = () => { return `${QUERY_TECHNICAL_MARK} SELECT PDiskFilter, @@ -14,7 +14,7 @@ SELECT CurrentAllocatedSize, CurrentGroupsCreated, AvailableGroupsToCreate -FROM \`${clusterRoot}/.sys/ds_storage_stats\` +FROM \`.sys/ds_storage_stats\` ORDER BY CurrentGroupsCreated DESC; `; }; diff --git a/src/store/reducers/executeTopQueries/executeTopQueries.ts b/src/store/reducers/executeTopQueries/executeTopQueries.ts index 1701eb8140..b7a5a85202 100644 --- a/src/store/reducers/executeTopQueries/executeTopQueries.ts +++ b/src/store/reducers/executeTopQueries/executeTopQueries.ts @@ -26,8 +26,8 @@ const slice = createSlice({ export const {setTopQueriesFilters} = slice.actions; export default slice.reducer; -const getQueryText = (database: string, filters?: TopQueriesFilters, sortOrder?: SortOrder[]) => { - const filterConditions = getFiltersConditions(database, filters); +const getQueryText = (filters?: TopQueriesFilters, sortOrder?: SortOrder[]) => { + const filterConditions = getFiltersConditions(filters); const orderBy = prepareOrderByFromTableSort(sortOrder); @@ -41,18 +41,14 @@ SELECT ReadBytes, UserSID, Duration -FROM \`${database}/.sys/top_queries_by_cpu_time_one_hour\` +FROM \`.sys/top_queries_by_cpu_time_one_hour\` WHERE ${filterConditions || 'true'} AND QueryText NOT LIKE '%${QUERY_TECHNICAL_MARK}%' ${orderBy} LIMIT 100 `; }; -function getRunningQueriesText( - database: string, - filters?: TopQueriesFilters, - sortOrder?: SortOrder[], -) { +function getRunningQueriesText(filters?: TopQueriesFilters, sortOrder?: SortOrder[]) { const filterConditions = filters?.text ? `Query ILIKE '%${filters.text}%' OR UserSID ILIKE '%${filters.text}%'` : ''; @@ -65,7 +61,7 @@ SELECT QueryStartAt, Query as QueryText, ApplicationName -FROM \`${database}/.sys/query_sessions\` +FROM \`.sys/query_sessions\` WHERE ${filterConditions || 'true'} AND Query NOT LIKE '%${QUERY_TECHNICAL_MARK}%' ${orderBy} LIMIT 100`; @@ -90,7 +86,7 @@ export const topQueriesApi = api.injectEndpoints({ try { const response = await window.api.viewer.sendQuery( { - query: getQueryText(database, preparedFilters, sortOrder), + query: getQueryText(preparedFilters, sortOrder), database, action: 'execute-scan', }, @@ -126,7 +122,7 @@ export const topQueriesApi = api.injectEndpoints({ try { const response = await window.api.viewer.sendQuery( { - query: getRunningQueriesText(database, filters, sortOrder), + query: getRunningQueriesText(filters, sortOrder), database, action: 'execute-scan', }, diff --git a/src/store/reducers/executeTopQueries/utils.ts b/src/store/reducers/executeTopQueries/utils.ts index 778690b804..03242cf0ad 100644 --- a/src/store/reducers/executeTopQueries/utils.ts +++ b/src/store/reducers/executeTopQueries/utils.ts @@ -5,13 +5,13 @@ import type {TopQueriesFilters} from './types'; const endTimeColumn = 'EndTime'; const intervalEndColumn = 'IntervalEnd'; -const getMaxIntervalSubquery = (database: string) => `( +const getMaxIntervalSubquery = () => `( SELECT MAX(${intervalEndColumn}) - FROM \`${database}/.sys/top_queries_by_cpu_time_one_hour\` + FROM \`.sys/top_queries_by_cpu_time_one_hour\` )`; -export function getFiltersConditions(database: string, filters?: TopQueriesFilters) { +export function getFiltersConditions(filters?: TopQueriesFilters) { const conditions: string[] = []; const to = dateTimeParse(Number(filters?.to) || filters?.to)?.valueOf(); const from = dateTimeParse(Number(filters?.from) || filters?.from)?.valueOf(); @@ -33,7 +33,7 @@ export function getFiltersConditions(database: string, filters?: TopQueriesFilte // If there is no filters, return queries, that were executed in the last hour if (!from && !to) { - conditions.push(`${intervalEndColumn} IN ${getMaxIntervalSubquery(database)}`); + conditions.push(`${intervalEndColumn} IN ${getMaxIntervalSubquery()}`); } if (filters?.text) { diff --git a/src/store/reducers/shardsWorkload/shardsWorkload.ts b/src/store/reducers/shardsWorkload/shardsWorkload.ts index 4f7d83de06..0f6230037d 100644 --- a/src/store/reducers/shardsWorkload/shardsWorkload.ts +++ b/src/store/reducers/shardsWorkload/shardsWorkload.ts @@ -42,9 +42,7 @@ function createShardQueryHistorical( filters?: ShardsWorkloadFilters, sortOrder?: SortOrder[], ) { - const pathSelect = database - ? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path` - : 'Path'; + const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`; let where = `Path='${path}' OR Path LIKE '${path}/%'`; @@ -65,16 +63,14 @@ SELECT PeakTime, InFlightTxCount, IntervalEnd -FROM \`${database}/.sys/top_partitions_one_hour\` +FROM \`.sys/top_partitions_one_hour\` WHERE ${where} ${orderBy} LIMIT 20`; } function createShardQueryImmediate(path: string, database: string, sortOrder?: SortOrder[]) { - const pathSelect = database - ? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path` - : 'Path'; + const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`; const orderBy = prepareOrderByFromTableSort(sortOrder); @@ -86,7 +82,7 @@ SELECT DataSize, NodeId, InFlightTxCount -FROM \`${database}/.sys/partition_stats\` +FROM \`.sys/partition_stats\` WHERE Path='${path}' OR Path LIKE '${path}/%' diff --git a/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts b/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts index 28686bb268..83ed2ea204 100644 --- a/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts +++ b/src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts @@ -2,11 +2,11 @@ import {QUERY_TECHNICAL_MARK, TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../ut import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../../utils/query'; import {api} from '../../api'; -const getQueryText = (database: string) => { +const getQueryText = () => { return `${QUERY_TECHNICAL_MARK} SELECT Path, SUM(DataSize) as Size -FROM \`${database}/.sys/partition_stats\` +FROM \`.sys/partition_stats\` GROUP BY Path ORDER BY Size DESC LIMIT ${TENANT_OVERVIEW_TABLES_LIMIT} @@ -20,7 +20,7 @@ export const topTablesApi = api.injectEndpoints({ try { const response = await window.api.viewer.sendQuery( { - query: getQueryText(database), + query: getQueryText(), database, action: 'execute-scan', }, diff --git a/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts b/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts index f09f20aebe..d5638147cf 100644 --- a/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts +++ b/src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts @@ -3,16 +3,13 @@ import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../../utils/que import {api} from '../../api'; function createShardQuery(path: string, database: string) { - const pathSelect = database - ? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path` - : 'Path'; - + const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`; return `${QUERY_TECHNICAL_MARK} SELECT ${pathSelect}, TabletId, CPUCores, -FROM \`${database}/.sys/partition_stats\` +FROM \`.sys/partition_stats\` WHERE Path='${path}' OR Path LIKE '${path}/%'