Repository navigation
feat(semantic layers): dashboard filters - #40475
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40475 +/- ##
==========================================
+ Coverage 64.72% 64.74% +0.01%
==========================================
Files 2686 2688 +2
Lines 148683 148887 +204
Branches 34322 34395 +73
==========================================
+ Hits 96240 96400 +160
- Misses 50678 50720 +42
- Partials 1765 1767 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
82a0eab to
5e46103
Compare
There was a problem hiding this comment.
Code Review Agent Run #37e9f4
Actionable Suggestions - 1
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts - 1
- SEMANTIC_DUPLICATION · Line 133-135
Additional Suggestions - 5
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx - 1
-
CWE-13616: Type Field Omitted in Column Object · Line 126-131The column object built from semantic view dimensions (lines 126-131) omits the `type` field, while the same transformation in `FiltersConfigForm.tsx` line 778 includes `type: dim.type`. This inconsistency means column metadata differs based on which component loaded it, which could cause unexpected behavior if downstream code expects the `type` field.
Code suggestion
--- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx (lines 126-131) --- 126: return { 127: column_name: dim.name, 128: + type: dim.type, 129: is_dttm: mappedType === GenericDataType.Temporal, 130: type_generic: mappedType, 131: filterable: true, 132: };
-
-
superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts - 1
-
Type should use DatasourceType enum · Line 41-41Using `string` type for `datasourceType` bypasses the existing `DatasourceType` enum which defines valid values (`Table`, `Query`, `Dataset`, `SlTable`, `SavedQuery`, `SemanticView`). This reduces type safety and allows invalid string values to be assigned. The three transformer files already using this field (`filterTransformer.ts`, `customizationTransformer.ts`, `utils.ts`) all assign from form inputs that should map to enum values. Aligning the type ensures compile-time validation and consistency with how `datasourceType` is typed elsewhere in the codebase.
Code suggestion
--- superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts +++ superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts @@ -17,6 +17,7 @@ */ import { AdhocFilter, DataMask } from '@superset-ui/core'; +import { DatasourceType } from './Datasource'; export interface ColumnOption { label: string; @@ -38,7 +39,7 @@ export interface NativeFilterScope { export interface NativeFilterTarget { datasetId: number; column: NativeFilterColumn; - datasourceType?: string; + datasourceType?: DatasourceType; // maybe someday support this? // show values from these columns in the filter options selector
-
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts - 1
-
Missing unit tests for transformer · Line 100-102The `buildFilterTarget` function now transforms `datasourceType` but lacks dedicated unit tests. Per rule [6262], tests should verify actual business logic (data transformation) not just component rendering. Add test coverage for `buildFilterTarget` covering `datasourceType` propagation.
-
-
superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx - 1
-
CWE-691: Redundant Label · Line 108-108The `parentLabelLower(item.kind)` label is semantically misleading for datasets. The function returns 'database' for non-semantic-view items, producing 'database: ' which is redundant — the database name is already shown below in StyledLabelDetail. This label adds noise without clarifying information.
-
-
superset-frontend/src/features/semanticLayers/label.ts - 1
-
Missing return type annotation · Line 76-77The new `parentLabelLower` function is missing an explicit return type hint. Per organizational standards, all functions should include explicit return type annotations for consistency and better static type checking.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx - 1
- Missing key in non-semantic path · Line 187-187
Review Details
-
Files reviewed - 23 · Commit Range:
6a82ead..31758e3- superset-core/src/superset_core/semantic_layers/types.py
- superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts
- superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.test.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.test.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/customizationTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/utils.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.test.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.ts
- superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx
- superset-frontend/src/features/semanticLayers/label.ts
- superset/semantic_layers/api.py
- superset/semantic_layers/mapper.py
- tests/unit_tests/semantic_layers/api_test.py
- tests/unit_tests/semantic_layers/mapper_test.py
-
Files skipped - 1
- superset-frontend/package-lock.json - Reason: Filter setting
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| if (formInputs.datasourceType) { | ||
| target.datasourceType = formInputs.datasourceType; | ||
| } |
There was a problem hiding this comment.
The added datasourceType assignment (lines 133-135) duplicates existing logic in filterTransformer.ts:100-101 and customizationTransformer.ts:95-96. This creates maintenance risk where future changes to this pattern require updates in three places. Consider extracting a shared helper function.
Code Review Run #37e9f4
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
31758e3 to
fe0def2
Compare
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| export const parentLabelLower = (kind?: string) => | ||
| kind === 'semantic_view' ? t('semantic layer') : t('database'); |
There was a problem hiding this comment.
Suggestion: This new label helper bypasses the existing sl(...) feature-flag logic and always uses "database" for non-semantic-view items, so when semantic layers are enabled the UI will show inconsistent terminology ("database" here vs "data connection" elsewhere). Route the fallback branch through the same feature-flag-aware label helper used by the other database labels. [logic error]
Severity Level: Major ⚠️
- ⚠️ Native filter dataset tooltip shows inconsistent parent label string.
- ⚠️ Semantic layers experience uses mixed "database" and "data connection" terms.Steps of Reproduction ✅
1. Observe that semantic-layer-aware labels use the `sl` helper in
`superset-frontend/src/features/semanticLayers/label.ts`: `databaseLabelLower` at lines
57–58 calls `sl(t('database'), t('data connection'))`, and `sl` itself at lines 30–32
returns the "semantic" label when `isFeatureEnabled(SEMANTIC_LAYERS_FLAG)` is true.
2. Note that the new `parentLabelLower` helper in the same file at lines 71–77 does not
use `sl` and instead hardcodes `t('semantic layer')` for `kind === 'semantic_view'` and
`t('database')` for all other kinds, so it never produces "data connection" even when
`SEMANTIC_LAYERS` is enabled.
3. Follow an actual caller:
`superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx` lines 16–31 render
a tooltip for datasets and call `parentLabelLower(item.kind)` on line 29 to render the
parent label before the database name in the tooltip description.
4. Trace how this label is used in real UI flows: `DatasetSelectLabel` is used by
`DatasetSelect` in
`superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx`
at lines 7–15 and 120–15, and `DatasetSelect` is used in the native filters config form
and in chart creation (`superset-frontend/src/pages/ChartCreation/index.tsx` lines 4–11).
When the `SemanticLayers` feature flag is enabled (checked via
`isFeatureEnabled(FeatureFlag.SemanticLayers)` in `DatasetSelect.tsx` line 32 and via
`SEMANTIC_LAYERS_FLAG` in `label.ts`), the rest of the UI shows "data connection" (e.g.,
`DatabaseList` uses `databaseLabelLower()` at
`superset-frontend/src/pages/DatabaseList/index.tsx` lines 5–8 and 80–82), but
`parentLabelLower` still renders "database" for non-`semantic_view` items, so a user
opening the dataset selector or native filter dataset tooltip will see inconsistent
terminology ("database: …" here vs "data connection" elsewhere).Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/features/semanticLayers/label.ts
**Line:** 76:77
**Comment:**
*Logic Error: This new label helper bypasses the existing `sl(...)` feature-flag logic and always uses "database" for non-semantic-view items, so when semantic layers are enabled the UI will show inconsistent terminology ("database" here vs "data connection" elsewhere). Route the fallback branch through the same feature-flag-aware label helper used by the other database labels.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| const newFormData = getFormData({ | ||
| ...filter, | ||
| datasetId, | ||
| datasourceType, |
There was a problem hiding this comment.
Suggestion: datasourceType is now part of the query payload, but it is not included in the effect dependency list that triggers data refreshes. If the datasource type changes while datasetId stays the same (the exact collision case this PR introduces), the effect can keep using stale form data and skip refetching, so filter options can come from the wrong datasource. Add datasourceType to the effect dependencies so switching datasource kind always rebuilds and reloads the filter query. [stale reference]
Severity Level: Major ⚠️
- ❌ Native filter options use columns from old datasource.
- ⚠️ Semantic view filters may query wrong backend dataset.Steps of Reproduction ✅
1. In the native filter configuration flow, `FiltersConfigForm` computes `datasetId` and
`datasourceType` for each filter (see
`superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx:11-23`),
where `datasetId` and `datasourceType` are derived from `filterToEdit?.targets?.[0]` /
`customizationToEdit?.targets?.[0]`.
2. `ColumnSelect` shows that datasets and semantic views can share the same numeric ID but
differ in `datasourceType` (see
`superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx:96-101`),
and explicitly constructs `datasourceKey = \`${datasetId}__${datasourceType || 'table'}\``
so switching between `'table'` and `'semantic_view'` with the same `datasetId` is a real,
supported scenario.
3. At runtime, `FilterControl` renders `FilterValue` for each native filter (see
`superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControl.tsx:20-34`),
and `FilterValue` destructures `datasetId` and `datasourceType` from `filter.targets[0]`
(see `FilterValue.tsx` around lines 28-37), then uses both when building `newFormData`
inside the `useEffect` shown in the PR hunk (lines 217-227), passing `datasetId` and
`datasourceType` into `getFormData`.
4. That `useEffect`'s dependency array (shown in `FilterValue.tsx` lines 193-206) includes
`datasetId` but not `datasourceType`, even though `datasourceType` participates in the
query payload (line 220). Therefore, when a filter's `targets[0].datasourceType` changes
(e.g., user switches from a physical dataset to a semantic view that reuses the same
`datasetId`, a scenario explicitly called out in `ColumnSelect.tsx:96-101`), it is
possible for all listed dependencies (`datasetId`, `dependencies`, `filter`, etc.) to
remain referentially unchanged while `datasourceType` changes, so this effect does not
rerun and `formData` stays bound to the old datasource kind, causing the filter query to
hit the wrong datasource until some other dependency changes or the dashboard reloads.Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
**Line:** 220:220
**Comment:**
*Stale Reference: `datasourceType` is now part of the query payload, but it is not included in the effect dependency list that triggers data refreshes. If the datasource type changes while `datasetId` stays the same (the exact collision case this PR introduces), the effect can keep using stale form data and skip refetching, so filter options can come from the wrong datasource. Add `datasourceType` to the effect dependencies so switching datasource kind always rebuilds and reloads the filter query.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Code Review Agent Run #15656f
Actionable Suggestions - 1
-
superset-core/src/superset_core/semantic_layers/types.py - 1
- Heterogeneous order comparison crash · Line 161-161
Additional Suggestions - 5
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts - 1
-
Incomplete type mapping coverage · Line 104-146The `mapSemanticTypeToGenericDataType` function fails to map several common SQL semantic types to generic data types. Types like 'tinyint', 'bigint', 'smallint', 'integer', 'numeric', 'varchar', and 'text' will return `undefined` instead of their appropriate `GenericDataType`. This affects filter column selection in dashboards when these common column types are used.
Code suggestion
--- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts +++ superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts @@ -127,7 +127,7 @@ export const mapSemanticTypeToGenericDataType = ( } if ( - /(\b(u?int\d*)\b|\bfloat\d*\b|\bdouble\b|\bdecimal\d*\b|\bnumber\b)/.test( + /(\b(u?int\d*)\b|\bfloat\d*\b|\bdouble\b|\bdecimal\d*\b|\bnumber\b|\b(big|small|tiny|medium)?int(eger)?\b|\bnumeric\b|\breal\b)/.test( normalized, ) ) { @@ -134,7 +134,7 @@ export const mapSemanticTypeToGenericDataType = ( } if ( - /(\bstr(ing)?\b|\butf8\b|\blarge_string\b|\bbinary\b|\bjson\b|\buuid\b)/.test( + /(\bstr(ing)?\b|\butf8\b|\blarge_string\b|\bbinary\b|\bjson\b|\buuid\b|\b(var)?char\d*\b|\btext\b)/.test( normalized, ) ) {
-
-
superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts - 1
-
Use DatasourceType enum not string · Line 41-41The field uses raw `string` type instead of the typed `DatasourceType` enum defined in `Datasource.ts`. This creates a type-safety gap: the codebase policy (AGENTS.md § TypeScript) explicitly prohibits `any`/untyped strings, and `Datasource` interface at line 43 correctly uses `type: DatasourceType`. Import `DatasourceType` and use the enum to match the established pattern.
Code suggestion
--- superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts +++ superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts @@ -18,6 +18,7 @@ */ import { AdhocFilter, DataMask } from '@superset-ui/core'; +import { DatasourceType } from './Datasource'; export interface ColumnOption { label: string; @@ -38,7 +39,7 @@ export interface NativeFilterScope { export interface NativeFilterTarget { datasetId: number; column: NativeFilterColumn; - datasourceType?: string; + datasourceType?: DatasourceType; // maybe someday support this? // show values from these columns in the filter options selector
-
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts - 2
-
Type consistency: string vs enum · Line 57-57The `datasourceType?: string` on line 57 uses a plain string type. Elsewhere in the codebase (e.g., `Dashboard.ts:41`, `superset-ui-chart-controls/src/types.ts:73`), `DatasourceType` enum is used for datasource type values. For consistency and type safety, consider `datasourceType?: DatasourceType`.
-
Type consistency: string vs enum · Line 95-95The `datasourceType?: string` on line 95 uses a plain string type. For consistency with `NativeFiltersFormItem` (line 57) and `DatasourceType` enum usage elsewhere, consider `datasourceType?: DatasourceType`.
-
-
superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx - 1
-
Schema fallback removed · Line 111-115The schema display logic changed from showing 'Schema: Not defined' for invalid schemas to silently hiding the schema row when invalid. This may be intentional UX improvement but removes explicit feedback about data quality issues. Consider documenting this behavior change or restoring the fallback if users need to see incomplete dataset metadata.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
superset/semantic_layers/mapper.py - 1
- Missing test for NOT_ILIKE · Line 583-583
Review Details
-
Files reviewed - 23 · Commit Range:
fe0def2..fe0def2- superset-core/src/superset_core/semantic_layers/types.py
- superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts
- superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.test.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.test.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/customizationTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/utils.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.test.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.ts
- superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx
- superset-frontend/src/features/semanticLayers/label.ts
- superset/semantic_layers/api.py
- superset/semantic_layers/mapper.py
- tests/unit_tests/semantic_layers/api_test.py
- tests/unit_tests/semantic_layers/mapper_test.py
-
Files skipped - 1
- superset-frontend/package-lock.json - Reason: Filter setting
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| column: Dimension | Metric | None | ||
| operator: Operator | ||
| value: FilterValues | frozenset[FilterValues] | ||
| value: FilterValues | tuple[FilterValues, ...] | frozenset[FilterValues] |
There was a problem hiding this comment.
The order=True decorator generates __lt__/__gt__ etc. comparing fields left-to-right. When value is a tuple in one Filter and a frozenset in another (both valid per the new union), Python raises TypeError: '<' not supported between instances of 'tuple' and 'frozenset' at runtime. This surfaces when set[Filter] is iterated or sorted. Either remove order=True or split into separate homogeneous dataclasses for each collection type.
Code suggestion
Check the AI-generated fix before applying
--- a/superset-core/src/superset_core/semantic_layers/types.py
+++ b/superset-core/src/superset_core/semantic_layers/types.py
@@ -153,7 +153,7 @@ class PredicateType(enum.Enum):
HAVING = "HAVING"
-@dataclass(frozen=True, order=True)
+@dataclass(frozen=True)
class Filter:
type: PredicateType
column: Dimension | Metric | None
Code Review Run #15656f
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
richardfogaca
left a comment
There was a problem hiding this comment.
Posting on Richard's behalf - this is his PR reviewer agent. Forward any pushback to him and he'll loop me back in.
Left two notes below - both are about semantic-view behavior diverging from the datasource type that the PR is now carrying through the filter config. All line numbers verified against HEAD fe0def2.
Functional - worth checking before merge
-
superset/semantic_layers/mapper.py:582-583The native filter UI still offers the text match modes as
ILIKE, but semantic-view queries currently collapseILIKEandNOT_ILIKEintoLIKEandNOT_LIKE. That makes contains / starts-with / ends-with filters case-sensitive or case-insensitive depending on the semantic backend's collation, which can diverge from what the dashboard author selected.WDYT - could we either carry explicit case-insensitive operators through the semantic-layer contract, or disable those match types for semantic views until that behavior is supported end to end?
-
superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts:310-320Chart customizations now persist
targets[].datasourceType, but this matching path still compares only the numeric ID parsed fromform_data.datasource. Since tables and semantic views have independent ID spaces, a customization targeting semantic view1can also match a chart on table1here, and the same ID-only comparison is used when deriving related charts insuperset-frontend/src/dashboard/util/getRelatedCharts.ts:126-142.Could we include the parsed datasource type in these comparisons as well, so semantic-view customizations only apply to
__semantic_viewcharts?
Praise
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx:64The composite select value is a nice way to avoid dataset / semantic-view ID collisions inside
AsyncSelectwhile still handing the rest of the form the numeric ID shape it already expects.
kgabryje
left a comment
There was a problem hiding this comment.
All good from my side, looks ready to merge once Richard's comment is addressed
rusackas
left a comment
There was a problem hiding this comment.
Bot feedback incoming!
The one I'd want settled before merging is the ID-only match in
getFormDataWithExtraFilters.tsandgetRelatedCharts.ts- now that targets carrydatasourceType, a customization on semantic_view1looks like it'd still match a chart on table1there since those consumers weren't touched. Is that a real collision, or am I missing where it's disambiguated?
dbb9217 to
4492d10
Compare
There was a problem hiding this comment.
Code Review Agent Run #1a039c
Actionable Suggestions - 3
-
tests/unit_tests/semantic_layers/api_test.py - 1
- Test incomplete assertion coverage · Line 2207-2207
-
superset-frontend/src/features/semanticLayers/label.ts - 1
- Missing unit test coverage · Line 76-77
-
superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx - 1
- Missing semantic_view tests · Line 108-108
Additional Suggestions - 3
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx - 1
-
Missing test for semantic layers integration · Line 174-191No test coverage exists for the new `handleChange` (lines 174-191) and `selectValue` (lines 161-167) logic paths that activate when the `SemanticLayers` feature flag is enabled. The existing tests at lines 268-312 test `loadDatasetOptions` in isolation but do not exercise the component's internal conversion of numeric IDs to/from composite strings. Without these tests, if `isFeatureEnabled` is mocked incorrectly or the conversion functions change, the integration will silently break.
-
-
superset-frontend/src/dashboard/components/nativeFilters/utils.ts - 1
-
Missing test for datasourceType · Line 81-82The new `datasourceType` parameter (lines 49, 66) lacks test coverage. The existing test at utils.test.ts:89-102 calls `getFormData` without this parameter, so the fallback to 'table' isn't explicitly validated when a type IS provided. Per rule [6262], tests should verify actual business logic, not just rendering.
-
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx - 1
-
Type shape mismatch · Line 1189-1189The `datasetInfo` field receives the full `value` object which includes `kind?: string`, but `NativeFiltersFormItem.datasetInfo` type expects `{ label, value, table_name? }` without `kind`. This creates a type inconsistency where extra properties may leak through. While TypeScript's structural typing allows this, downstream consumers expecting only documented fields could behave unexpectedly.
-
Review Details
-
Files reviewed - 29 · Commit Range:
5bbca69..28e1cf5- superset-core/src/superset_core/semantic_layers/types.py
- superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts
- superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.test.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.test.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/buildTarget.test.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/buildTarget.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/customizationTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/utils.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.test.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.ts
- superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
- superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
- superset-frontend/src/dashboard/util/getRelatedCharts.test.ts
- superset-frontend/src/dashboard/util/getRelatedCharts.ts
- superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx
- superset-frontend/src/features/semanticLayers/label.ts
- superset/semantic_layers/api.py
- superset/semantic_layers/mapper.py
- tests/unit_tests/semantic_layers/api_test.py
- tests/unit_tests/semantic_layers/mapper_test.py
-
Files skipped - 1
- superset-frontend/package-lock.json - Reason: Filter setting
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| mock_dim.grain = None | ||
|
|
||
| mock_view = MagicMock() | ||
| mock_view.name = "customers" |
There was a problem hiding this comment.
The mock_view.name is set to "customers" on line 2207, but unlike test_get_semantic_view_structure (which has the matching assertion on line 2124), this test lacks verification that the name is present in the API response. Per BITO.md rule [6262], tests must validate actual business logic, not merely confirm components render without errors.
Code Review Run #1a039c
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
| export const parentLabelLower = (kind?: string) => | ||
| kind === 'semantic_view' ? t('semantic layer') : t('database'); |
There was a problem hiding this comment.
The new parentLabelLower function has no unit tests. Per BITO.md rules [6262] and [11730], new tools/functions should have comprehensive unit tests covering success paths, error scenarios, and edge cases.
Code Review Run #1a039c
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
| {item.schema && isValidValue(item.schema) | ||
| ? item.schema | ||
| : t('Not defined')} | ||
| {parentLabelLower(item.kind)}:{' '} |
There was a problem hiding this comment.
The new parentLabelLower(item.kind) call at line 108 changes display behavior based on item.kind === 'semantic_view' vs undefined, but DatasetSelect.test.tsx only tests regular datasets without kind set. Add coverage for semantic_view to verify the label transformation logic per rule 6262. Also, schema: string in the type (line 33) should be schema?: string to match the optional guard used on lines 111-114.
Code Review Run #1a039c
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
mikebridge
left a comment
There was a problem hiding this comment.
Nice work — solid, well-tested feature, cleanly gated behind SEMANTIC_LAYERS; requesting changes only for a couple of frontend type-safety items before merge.
Should fix before merge
-
Unify
datasourceTypeon theDatasourceTypeenum. The field is the enum intypes.ts/buildTarget.ts/Dashboard.ts, but the form/control path types it as a barestringand branches on hand-written'semantic_view'/'table'literals in ~8 places — e.g.FiltersConfigForm.tsx:411,getControlItemsMap.tsx:51,ColumnSelect.tsx:43,nativeFilters/utils.ts:1323,FilterValue.tsx:145. It only works because the enum values happen to equal those strings. Standardize onDatasourceType.SemanticView/DatasourceType.Tableeverywhere so the enum's exhaustiveness actually buys us something. -
Drop the
as unknown ascast indoesChartMatchFilterDatasource(FiltersConfigModal/FiltersConfigForm/utils.ts:1026). The double cast to reachdatasource_typedisables structural checking becauseDatasourcesStatedoesn't declare the field. Add it to the type and drop the cast; if it isn't guaranteed at runtime, the fallback is silently relying onundefined.
Also: fill in the PR description/testing instructions (both blank) and drop the unrelated package-lock.json churn.
This review was generated by Claude (AI) on behalf of @mikebridge.
Fix label Fix lint and tests Address comments
28e1cf5 to
58c1f10
Compare
There was a problem hiding this comment.
Code Review Agent Run #768548
Actionable Suggestions - 1
-
superset-frontend/src/dashboard/types.ts - 1
- Mismatch: TS type added, backend not serializing · Line 234-236
Additional Suggestions - 1
-
superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts - 1
-
Use enum instead of any cast · Line 581-581Use the `DatasourceType` enum from `@superset-ui/core` instead of a string literal cast to `any`. The enum is already defined in `packages/superset-ui-core/src/query/types/Datasource.ts` as `SemanticView = 'semantic_view'`, so importing it eliminates the type workaround.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
superset-frontend/src/features/semanticLayers/label.ts - 1
- Incomplete kind branch coverage · Line 76-77
-
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx - 1
- Missing column reset in SemanticView branch · Line 118-145
Review Details
-
Files reviewed - 30 · Commit Range:
5a92459..58c1f10- superset-core/src/superset_core/semantic_layers/types.py
- superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts
- superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.test.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DatasetSelect.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.test.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/buildTarget.test.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/buildTarget.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/customizationTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts
- superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts
- superset-frontend/src/dashboard/components/nativeFilters/utils.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.test.ts
- superset-frontend/src/dashboard/reducers/dashboardInfo.ts
- superset-frontend/src/dashboard/types.ts
- superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
- superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
- superset-frontend/src/dashboard/util/getRelatedCharts.test.ts
- superset-frontend/src/dashboard/util/getRelatedCharts.ts
- superset-frontend/src/features/datasets/DatasetSelectLabel/index.tsx
- superset-frontend/src/features/semanticLayers/label.ts
- superset/semantic_layers/api.py
- superset/semantic_layers/mapper.py
- tests/unit_tests/semantic_layers/api_test.py
- tests/unit_tests/semantic_layers/mapper_test.py
-
Files skipped - 1
- superset-frontend/package-lock.json - Reason: Filter setting
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
rusackas
left a comment
There was a problem hiding this comment.
Nice work @betodealmeida, LGTM. The code notes from Richard and mikebridge all look handled now, so approving!
Couple of housekeeping bits before you merge if you don't mind: the testing instructions are still blank, and there's a little stray package-lock.json churn worth dropping. Neither blocks it.
…, not id alone Semantic views and regular datasets have independent numeric-id sequences, but two surfaces resolved their bound datasource by id only, silently reading whatever regular dataset shared the view's number (sc-111089, QA TC13/TC16): - The Dynamic group by display control's FilterBar loader fetched /api/v1/dataset/<id> ignoring the persisted targets[0].datasourceType, offering the colliding dataset's columns with no error. - useDatasetDrillInfo parsed the id__type composite and discarded the type, so the drill modal's metadata (name, verbose_map) came from the colliding dataset. The fix extends the apache#40475 type-aware pattern at a shared resolution point: - Extract fetchSemanticViewStructure/semanticViewDimensionsToColumns from the two shipped inline copies (ColumnSelect, FiltersConfigForm) and migrate them behaviour-preservingly. - New useDisplayControlDatasource hook: type-branched resolution with a monotonic request-id stale-response guard, inert on unbound controls; the dataset branch preserves the legacy request byte-for-byte (characterization tests authored pre-change). - Preserve datasourceType at both target-rewrite sites (handleColumnChange and the FilterBar clear path) — without this the binding silently degraded to the colliding dataset after the user's first select+apply. - useDatasetDrillInfo: the semantic_view branch short-circuits before the load.drillby.options extension check (the extension receives only the numeric id); metadata rows the structure payload cannot fill render their explicit not-available state, pinned by test. - Drop the display-control effect's dead `dependencies` coupling (the request never used it). Spec-kit artifacts (design, the 3-lens review that found the write-site self-revert, and the QA handoff notes) are tracked in the internal spec repo under sc-111089-groupby-id-collision. Co-Authored-By: Claude Fable 5 <[email protected]>
…, not id alone Semantic views and regular datasets have independent numeric-id sequences, but two surfaces resolved their bound datasource by id only, silently reading whatever regular dataset shared the view's number (sc-111089, QA TC13/TC16): - The Dynamic group by display control's FilterBar loader fetched /api/v1/dataset/<id> ignoring the persisted targets[0].datasourceType, offering the colliding dataset's columns with no error. - useDatasetDrillInfo parsed the id__type composite and discarded the type, so the drill modal's metadata (name, verbose_map) came from the colliding dataset. The fix extends the apache#40475 type-aware pattern at a shared resolution point: - Extract fetchSemanticViewStructure/semanticViewDimensionsToColumns from the two shipped inline copies (ColumnSelect, FiltersConfigForm) and migrate them behaviour-preservingly. - New useDisplayControlDatasource hook: type-branched resolution with a monotonic request-id stale-response guard, inert on unbound controls; the dataset branch preserves the legacy request byte-for-byte (characterization tests authored pre-change). - Preserve datasourceType at both target-rewrite sites (handleColumnChange and the FilterBar clear path) — without this the binding silently degraded to the colliding dataset after the user's first select+apply. - useDatasetDrillInfo: the semantic_view branch short-circuits before the load.drillby.options extension check (the extension receives only the numeric id); metadata rows the structure payload cannot fill render their explicit not-available state, pinned by test. - Drop the display-control effect's dead `dependencies` coupling (the request never used it). Spec-kit artifacts (design, the 3-lens review that found the write-site self-revert, and the QA handoff notes) are tracked in the internal spec repo under sc-111089-groupby-id-collision. Co-Authored-By: Claude Fable 5 <[email protected]>
…, not id alone Semantic views and regular datasets have independent numeric-id sequences, but two surfaces resolved their bound datasource by id only, silently reading whatever regular dataset shared the view's number (sc-111089, QA TC13/TC16): - The Dynamic group by display control's FilterBar loader fetched /api/v1/dataset/<id> ignoring the persisted targets[0].datasourceType, offering the colliding dataset's columns with no error. - useDatasetDrillInfo parsed the id__type composite and discarded the type, so the drill modal's metadata (name, verbose_map) came from the colliding dataset. The fix extends the apache#40475 type-aware pattern at a shared resolution point: - Extract fetchSemanticViewStructure/semanticViewDimensionsToColumns from the two shipped inline copies (ColumnSelect, FiltersConfigForm) and migrate them behaviour-preservingly. - New useDisplayControlDatasource hook: type-branched resolution with a monotonic request-id stale-response guard, inert on unbound controls; the dataset branch preserves the legacy request byte-for-byte (characterization tests authored pre-change). - Preserve datasourceType at both target-rewrite sites (handleColumnChange and the FilterBar clear path) — without this the binding silently degraded to the colliding dataset after the user's first select+apply. - useDatasetDrillInfo: the semantic_view branch short-circuits before the load.drillby.options extension check (the extension receives only the numeric id); metadata rows the structure payload cannot fill render their explicit not-available state, pinned by test. - Drop the display-control effect's dead `dependencies` coupling (the request never used it). Spec-kit artifacts (design, the 3-lens review that found the write-site self-revert, and the QA handoff notes) are tracked in the internal spec repo under sc-111089-groupby-id-collision. Co-Authored-By: Claude Fable 5 <[email protected]>
SUMMARY
Allow using semantic views in dashboard filters.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION