Repository navigation
feat: create SQL query dashboard filters and fill their dropdowns - #3678
karl-power wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: e9c4dca 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 |
Add a "SQL query values" type to the dashboard filter editor and populate the filter's dropdown from its query. - Render the filter's query in common-utils: expand time macros and other filters' variables, select the first column as a string, and cap the result at 10,000 rows - Run each SQL query filter's query on its connection and merge the values and errors into the dashboard's filter values - Keep the query's row order in the dropdown and show a caution while a referenced variable has no selection - Add the editor form: connection picker, SQL editor with macro and variable autocomplete, variable name, and an on-demand preview of the values over the dashboard's time range Refs HDX-5524
cf6ccc5 to
d411792
Compare
Duplicate code analysis2 new clones introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
E2E Test Results✅ All tests passed • 467 passed • 1 skipped • 1172s
Tests ran across 4 shards in parallel. |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
PR Review
5 finding(s): 🔴 0 critical · 🟠 2 major · 🔵 3 minor 2 posted as inline comment(s) on the changed lines. 3 listed below. Findings outside the changed lines
2 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. No P0/P1 issues surfaced. The user-SQL execution path was the main risk and holds up: 🟡 P2 -- recommended
🔵 P3 nitpicks (3)
Reviewers (4 of 11 reported before synthesis): testing, maintainability, performance, previous-comments. The orchestrator additionally ran inline verification of the param heuristic, Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
- Reject interval macros in SQL query filters, which have no time buckets - Validate the SQL on save against the dashboard's other variables - Build the editor's unsupported-macro list from the shared constants - Show the preview loader while a re-run fetches
|
Addressed the findings outside the changed lines in e9c4dca:
The jscpd clone with |
Summary
Adds the "SQL query values" dashboard filter type to the UI: users can create the filter, and its dropdown lists the first column of a ClickHouse query. This is the last PR in the stack; earlier PRs added the schema (#3672) and API/MCP support (#3674).
renderSqlQueryFilterValuesQueryin common-utils expands time macros and other filters' variables, wraps the SQL asSELECT toString(tupleElement(tuple(*), 1)) AS value FROM (...) LIMIT 10000, and strips a trailing;. Time params are sent only when the SQL uses them.useSqlQueryFilterValuesruns each filter's query on its connection withmax_execution_time: 30. Nulls, empty strings and duplicates are dropped, and the query's order is kept, so the dropdown doesn't sort these values.useDashboardFilterValuesmerges these values and errors with the other filter types. A query error shows as the dropdown's caution, as do variables the query references that have no selection yet.$__sourceTableand$__filtersare left out, since the filter has no source), and the variable name. The filter is variable-only, so there are no broadcast or variable toggles.Screenshots or video
Untitled.mov
How to reproduce
On
main:On this branch:
Service, pick the demo connection, and enter:svc, click Save filter, and close the modal. The Service dropdown lists the same services in the query's order.Severitywith optionsINFOandERRORand variablesev. Change the SQL to addAND $__filter(SeverityText, $sev). Picking a severity narrows the Service dropdown.SELECT nope FROM default.otel_logsand preview. The preview shows the ClickHouse error, and after saving, the dropdown shows it as a caution.References