-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add QUERY_TECHNICAL_MARK to all UI queries #1992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I see here path and database can exist simulteneously There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example: we look at shards of a table There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| filters, | ||
| sortOrder, | ||
| database, | ||
| ), | ||
| database, | ||
| action: queryAction, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If database is empty (as far as I can see - it can be '' because we are checking its value in ternary above) - will /.sys/... be okay as select source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.syswill work,/.sys- won't. However, we alway sent request to specific database, otherwise queries may not work at all (currently I have errors when I sent requests without defined database).I think it's better to remove ternaries - they have no sense.
Also I found more complex issue, we don't determine db correctly for nested entities, so for nested databases we have wrong db anyway. So actually, there is no difference, whether we pass database or not,
.syspath could be relative when db is passed. Probably I revert the changes where I add database to.syspathUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unneeded ternaries, database should never be empty or request won't be successful anyway. BTW, these ternaries were not needed even in case of empty string database, YQL processed it correctly, they were needed for the case of
undefineddatabase.Used relative paths everywhere: both in query text and api request we use the same param, so it never differs. If we use relative path, the query will use path from the database, that we passed.