Repository navigation
fix(semantic-layers): expose time grains in Explore for SemanticView datasources - #41456
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41456 +/- ##
=======================================
Coverage 64.80% 64.80%
=======================================
Files 2691 2691
Lines 149026 149077 +51
Branches 34393 34407 +14
=======================================
+ Hits 96569 96613 +44
- Misses 50691 50695 +4
- Partials 1766 1769 +3
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:
|
ebb0dc9 to
7da95e4
Compare
There was a problem hiding this comment.
Code Review Agent Run #d33c86
Actionable Suggestions - 1
-
tests/unit_tests/semantic_layers/mapper_test.py - 1
- Unused parameter in helper · Line 1007-1011
Additional Suggestions - 1
-
superset-frontend/src/explore/controlUtils/getSectionsToRender.ts - 1
-
Missing test for SemanticView · Line 70-73Added `DatasourceType.SemanticView` to `filterControlsForTypes` but no test exists for this new code path. Per rule [6262], tests should verify actual business logic — here the distinct filtering behavior (removing 'granularity' vs 'granularity_sqla'/'time_grain_sqla') for SemanticView types. Add a test case covering `DatasourceType.SemanticView` to prevent regressions as this datasource type matures.
-
Review Details
-
Files reviewed - 5 · Commit Range:
31199ae..7da95e4- superset-frontend/src/explore/controlUtils/getSectionsToRender.ts
- superset/semantic_layers/mapper.py
- superset/semantic_layers/models.py
- tests/unit_tests/semantic_layers/mapper_test.py
- tests/unit_tests/semantic_layers/models_test.py
-
Files skipped - 0
-
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
Reconcile with #41456: that PR sets ``expression=None`` on SV dimensions so a truthy ``expression`` (the "adhoc SQL column" signal) does not hide the time-grain selector. As a consequence, SV dimensions with empty ``expression`` land in the popover's Simple list, not the Saved list — the split in ``ColumnSelectPopover.tsx`` is done purely on ``expression`` truthiness. Disabling Simple would leave dimensions unreachable in the popover, so only Custom SQL stays disabled. - Drop ``'simple'`` from ``effectiveDisabledTabs`` in ``DndColumnSelect.tsx`` and ``DndColumnMetricSelect.tsx``; keep ``'sqlExpression'``. Update comments to explain the tie to #41456. - Rewrite the popover test to assert the new SV behavior (Simple enabled and selected by default; Custom SQL disabled; Saved enabled but not initial). Drop the ``as any`` cast per review. - Remove PR-added "Saved tab" comment blocks in ``models.py`` — they will be misleading once #41456 lands with its own ``expression`` rationale. - Remove the four ``expression == "..."`` assertions in ``models_test.py`` for the same reason. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
mikebridge
left a comment
There was a problem hiding this comment.
Nice change — this wires time-grain support through the SemanticView datasource path so it behaves like SqlaTable end-to-end, and the unit coverage is genuinely behavioral. No blockers — leaving this as a Comment with a few things worth tightening before merge.
-
Time-axis column silently dropped when no grain is selected and no raw variant exists (
mapper.py:309-316). The loop only appends variants wheredimension.grain == grain; a temporal column exposed only as grained variants (nograin=None), selected without a grain, matches nothing and drops out with no error — the chart loses its axis. Fall back to any available variant on no exact match, or guarantee a raw variant always accompanies grained ones. Add a test for this path. -
dimension.definitionis dropped, but the comment claims it's preserved (models.py:335).definitionisn't serialized anywhere. Either merge it intodescriptionor fix the comment to match the honest framing atmodels.py:365. -
_get_time_axis_columnpicks the first temporal column, which need not be the x-axis (mapper.py:900-932). With two temporal columns, the grain applies to whichever appears first. Identify the axis explicitly from the query context rather than a first-temporal heuristic.
This review was generated by Claude (AI) on behalf of @mikebridge.
7da95e4 to
3630037
Compare
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #61fa4aActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Reconcile with #41456: that PR sets ``expression=None`` on SV dimensions so a truthy ``expression`` (the "adhoc SQL column" signal) does not hide the time-grain selector. As a consequence, SV dimensions with empty ``expression`` land in the popover's Simple list, not the Saved list — the split in ``ColumnSelectPopover.tsx`` is done purely on ``expression`` truthiness. Disabling Simple would leave dimensions unreachable in the popover, so only Custom SQL stays disabled. - Drop ``'simple'`` from ``effectiveDisabledTabs`` in ``DndColumnSelect.tsx`` and ``DndColumnMetricSelect.tsx``; keep ``'sqlExpression'``. Update comments to explain the tie to #41456. - Rewrite the popover test to assert the new SV behavior (Simple enabled and selected by default; Custom SQL disabled; Saved enabled but not initial). Drop the ``as any`` cast per review. - Remove PR-added "Saved tab" comment blocks in ``models.py`` — they will be misleading once #41456 lands with its own ``expression`` rationale. - Remove the four ``expression == "..."`` assertions in ``models_test.py`` for the same reason. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3630037 to
a78e691
Compare
Code Review Agent Run #b7de59Actionable Suggestions - 0Additional Suggestions - 1
Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| elif axis_variants: | ||
| # No variant matches the requested grain. Prefer the raw (grain=None) | ||
| # variant; otherwise pick a deterministic fallback so the axis stays | ||
| # on the query instead of being silently dropped. | ||
| raw_variant = next((v for v in axis_variants if v.grain is None), None) | ||
| dimensions.append( | ||
| raw_variant | ||
| if raw_variant is not None | ||
| else min(axis_variants, key=lambda v: v.grain.name if v.grain else "") |
There was a problem hiding this comment.
superset/semantic_layers/mapper.py:366-374
When no time grain is requested at all and the time-axis column exposes only grained Dimension variants (no grain=None raw one), axis_match stays None here and the code falls through to min(axis_variants, key=lambda v: v.grain.name ...) — silently substituting an alphabetically-picked grain (e.g. "Day") for what should be raw data. _validate_granularity doesn't catch this since its grain-compatibility check only runs when a grain is actually requested.
Is it possible for a semantic view's time dimension to expose only grained variants with no raw one, or does the protocol guarantee a raw variant always exists? If it's possible, would it be worth surfacing an error (or defaulting more conservatively) instead of picking a grain silently here? WDYT?
This comment was generated by Claude (AI) on behalf of @eschutho.
eschutho
left a comment
There was a problem hiding this comment.
Just left one comment, but it looks good to me.
|
@sadpandajoe @eschutho it seems like this creates some duplication on
|
…overage Keep Saved-mode metric selection reachable for saved-only semantic views now that Simple is disabled, and lock in unchanged behavior for tables and for semantic views that declare ADHOC_COLUMN_EXPRESSIONS (expression-based Simple/Saved classification, defaults, search, Save, no failure warning). Strengthen the apache#41456 backend assertions so temporal semantic dimensions keep expression=None alongside the new feature serialization. Co-Authored-By: Claude Fable 5 <[email protected]>
…overage Keep Saved-mode metric selection reachable for saved-only semantic views now that Simple is disabled, and lock in unchanged behavior for tables and for semantic views that declare ADHOC_COLUMN_EXPRESSIONS (expression-based Simple/Saved classification, defaults, search, Save, no failure warning). Strengthen the apache#41456 backend assertions so temporal semantic dimensions keep expression=None alongside the new feature serialization. Co-Authored-By: Claude Fable 5 <[email protected]>
SUMMARY
This PR makes time grains work the same way for SemanticView datasources as they do for SqlaTable ones, end-to-end across the frontend control panel, the explorable serialization, the query mapper, and the validation layer. It does not require any change on the semantic-layer extension side beyond what the core protocol already specifies; extensions can emit (time-column × grain) Dimension variants and the rest just works.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
This is a Cube semantic layer, but it works with any extension:
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION