Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add verbose map to get /dataset/ endpoint #23655

Merged
merged 10 commits into from
Apr 26, 2023

Conversation

lilykuang
Copy link
Member

@lilykuang lilykuang commented Apr 12, 2023

SUMMARY

  • verbose_map field is missing in /v1/dataset/{id} response, the chart in drill by modal doesn't have access to verbose column and metric names.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Functional changes LGTM, but we need to add + update the schema. Also, we might want to consider DRYing the creation of verbose_map into a util.

superset/datasets/api.py Outdated Show resolved Hide resolved
@lilykuang lilykuang changed the title feat: add verbose map to /dataset/:id endpoint [WIP] feat: add verbose map to /dataset/:id endpoint Apr 13, 2023
@lilykuang lilykuang marked this pull request as ready for review April 13, 2023 18:48
@lilykuang lilykuang changed the title feat: add verbose map to /dataset/:id endpoint feat: add verbose map to get /dataset/ endpoint Apr 13, 2023
@codecov
Copy link

codecov bot commented Apr 13, 2023

Codecov Report

Merging #23655 (b307445) into master (6d55955) will increase coverage by 0.00%.
The diff coverage is 87.50%.

❗ Current head b307445 differs from pull request most recent head e02c80d. Consider uploading reports for the commit e02c80d to get more accurate results

@@           Coverage Diff           @@
##           master   #23655   +/-   ##
=======================================
  Coverage   68.02%   68.02%           
=======================================
  Files        1936     1937    +1     
  Lines       74929    74937    +8     
  Branches     8141     8143    +2     
=======================================
+ Hits        50970    50977    +7     
- Misses      21871    21872    +1     
  Partials     2088     2088           
Flag Coverage Δ
javascript 54.29% <87.50%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...tend/src/components/Chart/DrillBy/DrillByChart.tsx 100.00% <ø> (ø)
...tend/src/components/Chart/DrillBy/DrillByModal.tsx 72.54% <ø> (ø)
...perset-frontend/src/hooks/apiResources/datasets.ts 85.71% <85.71%> (ø)
.../src/components/Chart/DrillBy/DrillByMenuItems.tsx 90.14% <100.00%> (+0.14%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

The schema still appears to be broken:
image

Btw, as the elements of both columns and metrics contain verbose_name, could it potentially be more simple to just create a useVerboseName(dataset) hook in the frontend that extracts the verboseMap from the requested dataset?

superset/datasets/schemas.py Outdated Show resolved Hide resolved
superset/datasets/schemas.py Outdated Show resolved Hide resolved
@kgabryje
Copy link
Member

Btw, as the elements of both columns and metrics contain verbose_name, could it potentially be more simple to just create a useVerboseName(dataset) hook in the frontend that extracts the verboseMap from the requested dataset?

+1 to that! I had no clue that each column/metric contains its verbose_name, I assumed we can only take them from verbose_names on top level of dataset endpoint response

@kgabryje
Copy link
Member

I tested the PR and the charts in drill by modal still don't use the verbose names. I think in order to achieve that, we also need to pass the dataset object that contains verbose map to <SuperChart ... /> in DrillByChart

# Conflicts:
#	superset-frontend/src/components/Chart/DrillBy/DrillByChart.tsx
#	superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx
#	superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 21, 2023
setDataset(result);
const verbose_map = {};
ensureIsArray(result.columns).forEach((column: Column) => {
verbose_map[column.column_name] =
Copy link
Member

Choose a reason for hiding this comment

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

Could we move that to a separate file/hook? Like useVerboseMap?
The we could call it in DrillByChart like const verboseMap = useVerboseMap(dataset) and pass dataset to SuperChart like { ...dataset, verbose_map: verboseMap }
WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

And since that hook might have a more generic purpose, we could place it in src/hooks or src/utils instead of drill by directories

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

LGTM

@lilykuang lilykuang merged commit 369aafd into apache:master Apr 26, 2023
25 checks passed
@lilykuang lilykuang deleted the lily/add-verbose-map-to-dataset branch April 26, 2023 17:17
sebastianliebscher pushed a commit to sebastianliebscher/superset that referenced this pull request Apr 28, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants