Repository navigation
fix: filters.single_select drops an exclude instead of showing only the excluded value - #10280
Open
nishantmonu51 wants to merge 13 commits into
Open
nishantmonu51 wants to merge 13 commits into
nishantmonu51 wants to merge 13 commits into
Conversation
…mensions A single-select filter holds one value, so the frontend narrows anything else and used to turn an exclude into an include of the excluded value. - Explore and canvas `defaults.filters` must give a single-select dimension one value, `dim = 'x'` or `dim != 'x'`, and fail to reconcile otherwise. - A canvas filter control on a single-select dimension can't set `exclude: true`; `ValidateControls` reports it and drops the control.
…t excludes A single-select filter narrowed an exclude to an include of its last value, so an alert or report link, a bookmark or a default filter with `dim != 'x'` opened on `x` alone: the opposite of what it filtered. The filter now keeps excluding one value, and a value picked in the chip, a leaderboard or a chart is included as before. An exclude of several values keeps excluding the last of them, which shows more data than the original rather than the opposite. A canvas filter control on a single-select dimension drops a default it excludes instead of including it.
When the dashboard config arrived after the filter params were parsed, narrowing
a single-select filter went through the same path as a viewer's change: it
reported "filter-changed" and pushed a new history entry, so Back returned to the
unnarrowed url, which narrowed again.
Narrowing now commits quietly and writes the narrowed param with
`stateChanged({ replace: true })`, which `syncToUrl` turns into `goto(..., { replaceState: true })`.
A viewer's change in the same microtask still pushes a history entry.
…d one A filter control that excludes its default values holds one value once its dimension is listed under `filters.single_select`. Saving it in the control dialog wrote `exclude: false` with the first excluded value as the default, so the control showed only the value it was meant to leave out. The dialog still offers exclude only for a control that holds several values. A control that excludes its default but holds one value now shows an error and can't be saved until the builder clears the default or picks the value to include, which matches the runtime's check in `ValidateControls`.
…filter Explore writes its url from the explore state rather than through `syncToUrl`, so the replace from the previous fix didn't reach it: when the spec listed a filtered dimension under `filters.single_select` while the dashboard was open, the narrowed filter still pushed a history entry. `UrlParamsChangeTracker` exposes `isReplacing` while it emits "internal-change", and `DashboardStateSync.gotoNewState`, which that event reaches synchronously through the explore store, navigates with `replaceState` when it is set.
`metricssql.ParseFilter` builds `a AND b AND c` as `AND(AND(a, b), c)`, and the
check only looked inside the top-level AND, so a condition on a single-select
dimension anywhere but last in a filter with three or more conditions was
skipped: `country IN ('US', 'CA') AND device = 'mobile' AND os = 'ios'`
reconciled, and the frontend narrowed it to `country IN ('CA')`.
The check now flattens nested ANDs first, as the frontend's `flattenExpression`
does, and still leaves conditions under an OR alone. It also rejects a second
condition on the same single-select dimension, such as `foo != 'a' AND foo != 'b'`,
which would give the filter two values.
…alue `filters.required` with `filters.single_select` is how a dashboard shows exactly one value, for measures that mean nothing summed across values. An exclude meets the requirement while showing every other value, so a default such as `currency != 'USD'` on such a dimension now fails to reconcile, for explores and canvases. A single-select dimension that isn't required can still exclude one value.
…r a value An exclude counts as a value for the required filter gate, so a link, bookmark or default that excluded one value of a dimension listed under both `filters.required` and `filters.single_select` opened without the prompt and showed every other value combined, which that pair of settings exists to prevent. `narrowSingleSelectFilters` and `DimensionFilterManager.commit` now drop such an exclude, and the required filter asks for a value. The narrowing takes the dashboard config instead of a predicate, so it can tell whether a filter is required. A single-select filter that isn't required keeps excluding one value.
A single-select filter holds one included value, so `defaults.filters` must give
such a dimension `dim = 'x'` or `dim IN ('x')`. A `!=` or `NOT IN` default now fails
to reconcile on every single-select dimension, so the check no longer needs the
explore's or canvas's required filters.
A single-select filter can't exclude values. An exclude from a link, bookmark, default filter or late config is dropped: including the excluded value instead would show the opposite. This replaces keeping one excluded value, which needed a separate rule for required filters and extra handling when a value was picked. The control dialog drops the defaults an exclude control holds once it holds one value, as the canvas does, instead of blocking Save with an error.
A link that excludes values on a single-select filter opens without that filter, and its default must include one value. The AI instructions say so too.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For a dimension under
filters.single_select(#10172), an exclude filter turned into an include of the excluded value. An alert or report link, bookmark, public URL ordefaults.filterswithcountry != 'US'opened showing only US. A canvas filter control withexclude: trueon such a dimension (#10138) did the same.Single-select filters now don't support exclude:
NOT INor!=on a single-select dimension is dropped wherever it comes from: url parsing, param normalization, a config that loads after the params, or YAML defaults. The dashboard opens without that filter (or asks for a value if the filter is required), never on the opposite of it. AnINof several values still keeps the last one.ValidateControlsreports such a control.defaults.filtersmust give a single-select dimension one included value (dim = 'x'ordim IN ('x')), with one condition per dimension, checked through nested ANDs. Anything else fails to reconcile.single_selectisn't in a release yet, so no released project starts failing.Checklist: