Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6a6d8d7
log table sorting - ui logic
brandon-pereira Sep 30, 2025
7b57c18
implement sorting logic (blanket solution, needs to be dialed down pe…
brandon-pereira Sep 30, 2025
2086e6f
clean code
brandon-pereira Sep 30, 2025
569f372
fix bug where buttons show when loading
brandon-pereira Sep 30, 2025
943e2e8
make core table not contain sorting logic, move to parent component
brandon-pereira Oct 1, 2025
5df226e
improve ux of the table
brandon-pereira Oct 1, 2025
f02ee30
swap icons
brandon-pereira Oct 1, 2025
34cd889
use state instead of query params to support nested tables
brandon-pereira Oct 1, 2025
d32b164
correctly resolve aliases at inner level to avoid logic at parent
brandon-pereira Oct 1, 2025
b8c6f92
Merge branch 'main' into brandon/log-table-sorting
brandon-pereira Oct 1, 2025
5c7ac98
add tests for sorting
brandon-pereira Oct 1, 2025
9583adf
add changeset
brandon-pereira Oct 1, 2025
9858212
disable sorting on dynamic fields
brandon-pereira Oct 1, 2025
0cf8af6
add support to the db table chart component
brandon-pereira Oct 2, 2025
cf9cc5c
fix aliasing support
brandon-pereira Oct 2, 2025
0f6f73c
improve types to catch missing dateRange in future
brandon-pereira Oct 3, 2025
febfa64
fix linting
brandon-pereira Oct 3, 2025
393bd18
bug fixes
brandon-pereira Oct 6, 2025
eb37ae0
Merge branch 'main' into brandon/log-table-sorting
brandon-pereira Oct 6, 2025
e713c17
change initial sort logic
brandon-pereira Oct 6, 2025
0cfb723
tweak logic to correctly change sort only when sources changes
brandon-pereira Oct 6, 2025
c9d31ce
improve aliasing test
brandon-pereira Oct 6, 2025
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
5 changes: 5 additions & 0 deletions .changeset/young-eyes-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---

Add Sorting Feature to all search tables
50 changes: 40 additions & 10 deletions packages/app/src/ClickhousePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,31 @@ function InsertsTab({
</Text>
<DBTableChart
config={{
dateRange: searchedTimeRange,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the clickhouse inserts table, its currently broken in main

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, thanks for the heads up! Assigned the issue to you 👍

select: [
`count() as "Part Count"`,
`sum(rows) as Rows`,
'database as Database',
'table as Table',
'partition as Partition',
].join(','),
{
aggFn: 'count',
valueExpression: '',
alias: 'Part Count',
},
{
aggFn: 'sum',
valueExpression: 'rows',
alias: 'Rows',
},
{
valueExpression: 'database',
alias: 'Database',
},
{
valueExpression: 'table',
alias: 'Table',
},
{
valueExpression: 'partition',
alias: 'Partition',
},
],
from: {
databaseName: 'system',
tableName: 'parts',
Expand Down Expand Up @@ -661,10 +679,22 @@ function ClickhousePage() {
<DBTableChart
config={{
select: [
`count() as "Count"`,
`sum(query_duration_ms) as "Total Duration (ms)"`,
`any(query) as "Query Example"`,
].join(','),
{
aggFn: 'count',
valueExpression: '',
alias: `Count`,
},
{
aggFn: 'sum',
valueExpression: 'query_duration_ms',
alias: `Total Duration (ms)`,
},
{
aggFn: 'any',
valueExpression: 'query',
alias: `Query Example`,
},
],
dateRange: searchedTimeRange,
from,
where: `(
Expand Down
31 changes: 26 additions & 5 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
} from '@mantine/hooks';
import { notifications } from '@mantine/notifications';
import { useIsFetching } from '@tanstack/react-query';
import { SortingState } from '@tanstack/react-table';
import CodeMirror from '@uiw/react-codemirror';

import { ContactSupportText } from '@/components/ContactSupportText';
Expand All @@ -75,10 +76,7 @@ import { Tags } from '@/components/Tags';
import { TimePicker } from '@/components/TimePicker';
import WhereLanguageControlled from '@/components/WhereLanguageControlled';
import { IS_LOCAL_MODE } from '@/config';
import {
useAliasMapFromChartConfig,
useQueriedChartConfig,
} from '@/hooks/useChartConfig';
import { useAliasMapFromChartConfig } from '@/hooks/useChartConfig';
import { useExplainQuery } from '@/hooks/useExplainQuery';
import { withAppNav } from '@/layout';
import {
Expand All @@ -104,7 +102,10 @@ import PatternTable from './components/PatternTable';
import SourceSchemaPreview from './components/SourceSchemaPreview';
import { useTableMetadata } from './hooks/useMetadata';
import { useSqlSuggestions } from './hooks/useSqlSuggestions';
import { parseAsStringWithNewLines } from './utils/queryParsers';
import {
parseAsSortingStateString,
parseAsStringWithNewLines,
} from './utils/queryParsers';
import api from './api';
import { LOCAL_STORE_CONNECTIONS_KEY } from './connection';
import { DBSearchPageAlertModal } from './DBSearchPageAlertModal';
Expand Down Expand Up @@ -1155,6 +1156,24 @@ function DBSearchPage() {
[onSubmit],
);

const onSortingChange = useCallback(
(sortState: SortingState | null) => {
setIsLive(false);
const sort = sortState?.at(0);
setSearchedConfig({
orderBy: sort
? `${sort.id} ${sort.desc ? 'DESC' : 'ASC'}`
: defaultOrderBy,
});
},
[setIsLive, defaultOrderBy, setSearchedConfig],
);
// Parse the orderBy string into a SortingState. We need the string
// version in other places so we keep this parser separate.
const orderByConfig = parseAsSortingStateString.parse(
searchedConfig.orderBy ?? '',
);

const handleTimeRangeSelect = useCallback(
(d1: Date, d2: Date) => {
onTimeRangeSelect(d1, d2);
Expand Down Expand Up @@ -1831,6 +1850,8 @@ function DBSearchPage() {
onError={handleTableError}
denoiseResults={denoiseResults}
collapseAllRows={collapseAllRows}
onSortingChange={onSortingChange}
initialSortBy={orderByConfig ? [orderByConfig] : []}
/>
)}
</>
Expand Down
Loading
Loading