Skip to content

fix(dashboard): show one labelled drill choice per semantic dimension - #46374

Merged
mikebridge merged 4 commits into
apache:masterfrom
mikebridge:fix-drill-menu-duplicate-date-r2-20261119
Nov 20, 2026
Merged

mikebridge merged 4 commits into
apache:masterfrom
mikebridge:fix-drill-menu-duplicate-date-r2-20261119

Conversation

@mikebridge

@mikebridge mikebridge commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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_name to 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 selected column_name and 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

  1. On a dashboard with a semantic-view chart whose provider exposes several time grains, open the chart's Drill by submenu.
  2. Confirm each date dimension appears once under its display label and can be searched by that label.
  3. Select a date dimension and confirm the Drill by result still uses the same semantic member.
  4. Run the focused semantic-view structure API tests, shared mapper tests, Drill by submenu tests, and changed-file hooks.

ADDITIONAL INFORMATION

  • Has associated issue
  • Required feature flags: SEMANTIC_LAYERS, DRILL_BY
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API: additive nullable field on an existing response
  • Removes existing feature or API

@github-actions github-actions Bot added api Related to the REST API doc Namespace | Anything related to documentation labels Nov 19, 2026
@mikebridge
mikebridge marked this pull request as ready for review November 19, 2026 19:04
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 177fe1e766f1

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.71%. Comparing base (0c68380) to head (177fe1e).
⚠️ Report is 9 commits behind head on master.

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           
Flag Coverage Δ
hive 33.98% <100.00%> (-0.01%) ⬇️
javascript 82.41% <100.00%> (+<0.01%) ⬆️
mysql 51.65% <100.00%> (-0.01%) ⬇️
postgres 51.68% <100.00%> (+<0.01%) ⬆️
presto 35.67% <100.00%> (-0.01%) ⬇️
python 88.32% <100.00%> (+<0.01%) ⬆️
sqlite 51.35% <100.00%> (-0.01%) ⬇️
unit 83.61% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread superset/semantic_layers/api.py Outdated
"verbose_name": dim.verbose_name,
}
for dim in sorted(
view.implementation.get_dimensions(), key=lambda d: d.name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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).

Suggested change
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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mikebridge
mikebridge merged commit 87d8345 into apache:master Nov 20, 2026
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API doc Namespace | Anything related to documentation review:draft size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants