Repository navigation
fix(dashboard): show one labelled drill choice per semantic dimension - #46374
mikebridge merged 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46374 +/- ##
=======================================
Coverage 85.71% 85.71%
=======================================
Files 3113 3113
Lines 215307 215317 +10
Branches 51023 51025 +2
=======================================
+ Hits 184550 184559 +9
- Misses 27341 27342 +1
Partials 3416 3416
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:
|
rebenitez1802
left a comment
There was a problem hiding this comment.
Approve: this fixes the duplicate Drill by choices. Stored values stay column_name everywhere, so the new labels only change what's displayed, and the change also removes duplicate options from the display-control and pre-filter column lists. CI is green and the branch merges cleanly onto current master. One optional 🟡 inline: an order dependency in the structure endpoint, which also covers the follow-up listed in the description. Heads-up: this conflicts textually with your drafts #46281 and #46283 (api.py structure dict and the SemanticViewStructure type).
| "verbose_name": dim.verbose_name, | ||
| } | ||
| for dim in sorted( | ||
| view.implementation.get_dimensions(), key=lambda d: d.name |
There was a problem hiding this comment.
🟡 Medium — Without a raw variant, the label depends on hash order
get_dimensions() returns a set, and this endpoint sorts it by d.name only. Same-name grain variants therefore arrive in a hash order that changes from one worker process to the next. When a member has no grain == null variant, semanticViewDimensionsToColumns keeps whichever variant comes first. The label and type shown in Drill by and the display-control lists can then change between workers: one shows "Order day" (date32), another "Order year" (int64, not temporal). They can also disagree with Explore, which picks the finest grain consistently via grain_preference. Using that as a secondary sort key makes "first seen" in the mapper match Explore. This also covers the known follow-up in the PR description.
Also needs from superset.semantic_layers.dimension_resolution import grain_preference at the top of the file (outside the diff, so it can't go in the suggestion).
| view.implementation.get_dimensions(), key=lambda d: d.name | |
| view.implementation.get_dimensions(), | |
| key=lambda d: (d.name, grain_preference(d)), |
I checked it with a regression test that feeds Day/Week/Month/Year variants as a real set and expects them in fineness order. Under PYTHONHASHSEED 1–3 it fails without this change and passes with it, and the other structure tests still pass.
There was a problem hiding this comment.
Applied in 177fe1e. The structure response now sorts variants by member name and the shared grain preference, matching Explore's raw and finest-grain selection. A regression using a real set failed under three hash seeds before the change and passes under all three after it. The focused API tests and semantic-layer 100% coverage gate pass.
| const mappedType = mapSemanticTypeToGenericDataType(dim.type); | ||
| return { | ||
| column_name: dim.name, | ||
| verbose_name: dim.verbose_name || dim.name, |
There was a problem hiding this comment.
🟢 Low (optional) — The fallback adds a redundant tooltip
With || dim.name, unlabelled dimensions get verbose_name === column_name, so getColumnTooltipNode shows "Column name: X / Label: X" in the pre-filter column picker, where there was no tooltip before. Explore sends verbose_name: null, and every consumer already falls back to verbose_name || column_name, so keeping dim.verbose_name ?? undefined would be enough. The mapper test's verbose_name: 'Orders.order_ts' expectation would need updating too. Non-blocking.
There was a problem hiding this comment.
Applied in 177fe1e. An unlabelled dimension now keeps verbose_name absent in the mapped column. Drill by and the other inspected consumers still display the member name through their existing fallbacks. The mapper test failed before this change and passes afterward; both focused Jest suites and frontend type checking pass.
SUMMARY
TL;DR: The Drill by menu shows each semantic-view dimension once, using its display label when available. Selecting a choice still drills by the same member identity.
Background: A semantic view may expose several variants of a time dimension, one for each supported grain. The Drill by menu builds its choices from the semantic-view structure response.
Problem: Each grain variant appeared as a separate choice with the raw member name, so a date dimension could appear repeatedly. The structure response did not include the provider's display label.
Changes: Add nullable
verbose_nameto structure dimensions. Collapse grain variants by member name in the shared frontend mapper. For column metadata, prefer the raw variant, otherwise the finest grain, matching the variant Explore selects; the structure response lists variants in that order. Retain the provider label when present. Consumers display the member name when no label is supplied. The selectedcolumn_nameand query identifiers are unchanged.The same labels appear in the native-filter column picker when verbose names are shown, display-control column lists, and Drill by result labels.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: the menu could repeat a qualified date name for each supported grain. After: it shows one choice per dimension, using the provider label when available.
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
SEMANTIC_LAYERS,DRILL_BY