Repository navigation
feat: add SQL_QUERY dashboard filter type to the schema - #3672
karl-power wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 369bd81 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 |
🟡 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
|
989bc97 to
f94e9ab
Compare
E2E Test Results✅ All tests passed • 466 passed • 1 skipped • 1035s
Tests ran across 4 shards in parallel. |
Duplicate code analysis1 new clone introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
PR Review
5 finding(s): 🔴 0 critical · 🟠 2 major · 🔵 3 minor 5 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep ReviewSchema-only PR adding the ✅ No critical issues found. No P0/P1 ship-blockers: nothing introduces a guaranteed happy-path crash, data loss on a normal path, or an injection vector. The new union member, type guard, 🟡 P2 -- recommended
🔵 P3 nitpicks (4)
Pre-existing (not counted toward verdict)
Prior commentsAll four substantive prior threads were verified addressed in the current diff: connection mapping + block-until-mapped ( Reviewers (11): correctness, adversarial, kieran-typescript, api-contract, julik-frontend-races, testing, maintainability, project-standards, previous-comments, agent-native, learnings-researcher. 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 |
Add a variable-only dashboard filter whose dropdown values come from the first column of a ClickHouse query run on a connection. - Add SqlQueryDashboardFilterSchema and the isSqlQueryFilter guard - Validate the template's macros and variable references, rejecting $__sourceTable and $__filters - Export the filter's connection as a name in dashboard templates - Keep the type out of the external API and MCP for now Refs HDX-5524
dde72dc to
369bd81
Compare
| tooltip: 'Sources the condition keys and values come from', | ||
| label: getSourceNames(filter.sources, sources), | ||
| }; | ||
| case 'SQL_QUERY': |
There was a problem hiding this comment.
🟠 major — An imported SQL_QUERY filter can be edited, but the edit form drops its connection and SQL and can't save it
Imports can now create SQL_QUERY filters, and the filter list shows them with the usual edit pencil. Clicking it runs toFormValues (filterFormState.ts:60), which has no connection or sqlTemplate fields, so both values are lost. DashboardFilterEditForm.tsx:259 then falls through to QueryExpressionFilterEditForm, and the type picker shows nothing because FILTER_TYPE_OPTIONS has no SQL_QUERY entry. Saving hits the generic branch of toSavedFilter, and DashboardFilterSchema.parse throws ('This filter is incomplete…'). If the user switches the type instead, the SQL template is silently discarded. Until the editor PR lands, hide or disable the edit action for SQL_QUERY filters, or keep their fields in the form state and save them unchanged.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| return (filters ?? []).filter( | ||
| (filter): filter is ExternalCompatibleDashboardFilter => | ||
| !isAdhocFilter(filter), | ||
| !isAdhocFilter(filter) && !isSqlQueryFilter(filter), |
There was a problem hiding this comment.
🟠 major — MCP and external-API saves silently delete SQL_QUERY filters, breaking tiles that use their variable
These reads now hide SQL_QUERY filters, but the writes replace the whole filter array: MCP saveDashboard.ts:386-397 only re-adds hidden PromQL filters, and external PUT v2/dashboards.ts:3632 writes filters directly. So a GET→modify→save round trip removes every SQL_QUERY filter, and raw-SQL tiles referencing its $var lose their variable. Before hiding the type, carry existing internal-only filters (SQL_QUERY, and ADHOC too) through as hiddenFilters, the way PromQL filters are handled.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| {warning.where} | ||
| </Text> | ||
| {warning.detail && ( | ||
| <Text c="yellow" size="sm"> |
There was a problem hiding this comment.
🔵 minor — New warning detail text uses raw palette color c="yellow" instead of the semantic Text variant
The conventions say to use <Text variant="warning"> for status text rather than raw Mantine colors, and to migrate nearby call sites when you touch them. Use variant="warning" on the new detail Text and the reworked line above it (line 342).
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| * Why a SQL query filter's template can't expand, or undefined when it can. | ||
| * The SQL itself is not parsed: ClickHouse syntax is only checked when it runs. | ||
| */ | ||
| export function validateSqlQueryFilterTemplate( |
There was a problem hiding this comment.
🔵 minor — validateSqlQueryFilterTemplate is exported but nothing outside this file calls it
Its only caller is validateDashboardFilterQueries in the same module; grep finds no import in app, api or tests. Keep it module-private until the follow-up PR that needs it, or add a direct unit test so the export has a reason to exist.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| ]); | ||
|
|
||
| // Propagate connection mapping changes to other RawSQL tiles with the same input connection | ||
| // Propagate connection mapping changes to other RawSQL tiles and SQL query |
There was a problem hiding this comment.
🔵 minor — The rewritten connection-propagation effect has no test
This effect now propagates connection picks in both directions, tile→filter and filter→tile, using two separate prev-refs. The new tests only cover auto-mapping by name and the unmapped-connection error. Add a test with a raw-SQL tile and a SQL_QUERY filter that share a template connection: pick a connection on one row and assert the other row follows, and that a row the user already changed (dirty) is left alone.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
Summary
Adds the
SQL_QUERYdashboard filter type to the schema: a variable-only filter whose dropdown values come from the first column of a free-form ClickHouse query. This is the first of four PRs; it adds the data model and validation only, so the filter can't be created or used in the UI yet.SqlQueryDashboardFilterSchemastores aconnectionID and asqlTemplate, withisBroadcastEnabled: falseandisVariableEnabled: truefixed, since there's no column to broadcast.isSqlQueryFiltertype guard.validateDashboardFilterQueriesexpands the template with empty variable selections and flags$__sourceTable/$__filters(the filter has no source) and any macro or variable expansion error. The SQL itself isn't parsed; ClickHouse reports syntax errors when it runs.ADHOC, until they expose it.How to test on Vercel preview
N/A — non-UI change
References