Skip to content

Commit 5e708ca

Browse files
fix(TopQueries): use EndTime (#727)
1 parent 8af45b0 commit 5e708ca

File tree

1 file changed

+10
-4
lines changed
  • src/store/reducers/executeTopQueries

1 file changed

+10
-4
lines changed

src/store/reducers/executeTopQueries/utils.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import {ITopQueriesFilters} from './types';
22

3+
const endTimeColumn = 'EndTime';
4+
const intervalEndColumn = 'IntervalEnd';
5+
36
const getMaxIntervalSubquery = (path: string) => `(
47
SELECT
5-
MAX(IntervalEnd)
8+
MAX(${intervalEndColumn})
69
FROM \`${path}/.sys/top_queries_by_cpu_time_one_hour\`
710
)`;
811

@@ -17,15 +20,18 @@ export function getFiltersConditions(path: string, filters?: ITopQueriesFilters)
1720
// matching `from` & `to` is an edge case
1821
// other cases should not include the starting point, since intervals are stored using the ending time
1922
const gt = filters.to === filters.from ? '>=' : '>';
20-
conditions.push(`IntervalEnd ${gt} Timestamp('${new Date(filters.from).toISOString()}')`);
23+
conditions.push(
24+
`${endTimeColumn} ${gt} Timestamp('${new Date(filters.from).toISOString()}')`,
25+
);
2126
}
2227

2328
if (filters?.to) {
24-
conditions.push(`IntervalEnd <= Timestamp('${new Date(filters.to).toISOString()}')`);
29+
conditions.push(`${endTimeColumn} <= Timestamp('${new Date(filters.to).toISOString()}')`);
2530
}
2631

32+
// If there is no filters, return queries, that were executed in the last hour
2733
if (!filters?.from && !filters?.to) {
28-
conditions.push(`IntervalEnd IN ${getMaxIntervalSubquery(path)}`);
34+
conditions.push(`${intervalEndColumn} IN ${getMaxIntervalSubquery(path)}`);
2935
}
3036

3137
if (filters?.text) {

0 commit comments

Comments
 (0)