fix(app): sort builder tables by output identifiers - #2981
Conversation
🦋 Changeset detectedLatest commit: 3aa6af4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@fallintoplace is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThe PR fixes builder-table sorting by treating returned column names as quoted ClickHouse output identifiers and updates persisted sorting-state parsing to support quoted names containing spaces.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/app/src/components/DBTableChart.tsx | Builder columns now use escaped, quoted output identifiers while raw SQL and PromQL columns remain unchanged. |
| packages/app/src/utils.ts | The order-by parser now restores quoted identifiers containing spaces while retaining validation for unquoted identifiers. |
| packages/app/src/components/tests/DBTableChart.test.tsx | Adds typed fixtures and regression coverage for builder output identifiers, escaping, and generated server-side ordering. |
| packages/app/src/tests/utils.test.ts | Adds parsing and round-trip coverage for quoted sorting identifiers containing spaces. |
Reviews (2): Last reviewed commit: "fix(app): preserve quoted table sort sta..." | Re-trigger Greptile
| // Builder sorting runs against the final result, so every returned key | ||
| // must be treated as an output identifier rather than an expression. | ||
| id: isBuilderChartConfig(queriedConfig) |
There was a problem hiding this comment.
Quoted sort state cannot round-trip
When a builder output name contains spaces, such as error rate, its quoted ID is serialized as "error rate" DESC, but the existing parser splits on every space and rejects the resulting three tokens. After the chart remounts or reloads, the persisted ordering is not restored and the sort indicator and selected ordering are lost.
| direction: 'DESC' as const, | ||
| }, | ||
| }, | ||
| fetchNextPage: jest.fn(), |
There was a problem hiding this comment.
New mocks bypass type checking
The two added query mocks use as any, so changes to the query result contract will not be checked against these fixtures. Please give these mock return values their proper type so missing or malformed fields remain visible to TypeScript.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Deep Review✅ No critical issues found. The core change is sound: builder-table sort IDs are now quoted ClickHouse identifiers, escaping is applied backslash-first then double-quote-doubling ( 🔵 P3 nitpicks (3)
Reviewers (7): correctness, security, testing, maintainability, kieran-typescript, project-standards, previous-comments. Testing gaps: No integration-level test that a persisted quoted builder sort (spaces/special chars) round-trips through the ChartPreviewPanel order-by string back onto the matching column id. |
What changed
Builder table sorting now uses the returned column name as a quoted ClickHouse identifier.
This fixes sorting for:
avg(metric.total)Also:
Why
The composed metric query sorts in the outer result scope. The table was sending generated names as expressions, so ClickHouse could not resolve them.
The sort state parser also split on every space, so a quoted name like
"error rate" DESCwas lost after reload.Tests
yarn workspace @hyperdx/app jest --runInBand src/__tests__/utils.test.ts src/components/__tests__/DBTableChart.test.tsxyarn workspace @hyperdx/app tsc --noEmityarn lint:fix