feat: add custom ORDER BY expression for Log and Trace sources#1856
feat: add custom ORDER BY expression for Log and Trace sources#1856
Conversation
Allow users to configure a custom ORDER BY clause per source that overrides the default auto-computed ordering on the search page. This supports deployments where the default sort order doesn't align with the table's ordering keys (e.g. disabled read-in-order optimization). Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 865cc8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
|
Claude finished @dhable's task in 57s —— View job PR Review
✅ No critical issues found. The implementation is clean and well-tested. A few minor observations:
|
Made-with: Cursor
|
Claude finished @dhable's task in 27s —— View job PR Review✅ No critical issues found. The implementation is clean — schema, model, UI, and query logic are all consistent. A few minor observations:
|
E2E Test Results✅ All tests passed • 85 passed • 3 skipped • 973s
Tests ran across 4 shards in parallel. |
Validate the orderByExpression field using EXPLAIN ESTIMATE queries against ClickHouse, matching the existing HighlightedAttributeRow validation pattern. Shows inline valid/invalid feedback with debounced auto-validation and a manual validate button. Made-with: Cursor
|
Claude finished @dhable's task in 40s —— View job PR Review✅ No critical issues found. The implementation is clean and well-structured. A few observations:
|
The custom ORDER BY is applied as a silent default fallback in the chart config, not written into the CodeMirror editor. Changed the test to verify persistence via GET /sources and that search results load successfully with the custom ORDER BY. Made-with: Cursor
|
Claude finished @dhable's task in 31s —— View job PR Review
✅ No critical issues found. The implementation is clean and well-structured across schema, model, UI, and query logic. The previous validation concern is addressed — One minor note: |
|
Claude finished @dhable's task in 29s —— View job PR Review✅ No critical issues found. The implementation is clean and well-structured. The previous validation concern is fully addressed —
|
| tableName: z.string().min(1, 'Table is required'), | ||
| }), | ||
| querySettings: QuerySettingsSchema.optional(), | ||
| orderByExpression: z.string().optional(), |
There was a problem hiding this comment.
Should this be added to LogSourceAugmentation and TraceSourceAugmentation instead, since it is not supported on Session and Metric sources?
| <InputControlled | ||
| control={control} | ||
| name="orderByExpression" | ||
| placeholder="e.g. Timestamp DESC" | ||
| /> |
There was a problem hiding this comment.
Can we use SQLInlineEditorControlled here since the input is sql, for consistent styling / syntax highlighting with other SQL inputs, and for auto complete?
| {shouldShowResult && ( | ||
| <Box> | ||
| {isExpressionValid && ( | ||
| <Text c="green" size="xs"> | ||
| Expression is valid. | ||
| </Text> | ||
| )} | ||
| {isExpressionInvalid && ( | ||
| <ErrorCollapse | ||
| summary="Expression is invalid" | ||
| details={explainError?.message} | ||
| /> | ||
| )} |
| label="Order By" | ||
| helpText="Custom ORDER BY expression that overrides the default ordering. Leave empty to use the auto-detected default." |
There was a problem hiding this comment.
super nit - for consistency with Default Select
| label="Order By" | |
| helpText="Custom ORDER BY expression that overrides the default ordering. Leave empty to use the auto-detected default." | |
| label="Default Order By" | |
| helpText="Custom ORDER BY expression that overrides the default ordering. Leave empty to use the auto-detected default. (This can be customized per search later)" |

Allow users to configure a custom ORDER BY clause per source that overrides the default auto-computed ordering on the search page. This supports deployments where the default sort order doesn't align with the table's ordering keys (e.g. disabled read-in-order optimization).
Made-with: Cursor
Summary
Screenshots or video
How to test locally or on Vercel
References