Skip to content

fix(explore): keep certification badges after saving or swapping a dataset - #43319

Merged
rusackas merged 2 commits into
apache:masterfrom
s1ny1998:fix/explore-dataset-certification-rehydrate
Aug 28, 2026
Merged

rusackas merged 2 commits into
apache:masterfrom
s1ny1998:fix/explore-dataset-certification-rehydrate

Conversation

@s1ny1998

Copy link
Copy Markdown
Contributor

SUMMARY

Saving a dataset from Explore (... beside the dataset name → Edit dataset → Save), or swapping the chart's dataset, temporarily cleared the Certified / Warning icons and the Certified field values for metrics, columns and calculated columns. A full page refresh restored them, so nothing was actually lost on the backend — Explore's client state was simply missing the fields.

Both flows rehydrate the Explore datasource from GET /api/v1/dataset/:id (DatasourceModal after the PUT, and ChangeDatasourceModal on swap), and hand the response straight to changeDatasource() → SET_DATASOURCE.

That payload was missing the certification metadata. show_select_columns exposes columns.extra and metrics.extra, but not the attributes derived from extra — is_certified, certified_by, certification_details and warning_markdown — which are @property values on CertificationMixin. The Explore bootstrap serialization (TableColumn.data / SqlMetric.data) does include them, which is why a refresh fixed it.

This adds those four fields, for both columns and metrics, to show_columns so the REST endpoint matches the serialization Explore already expects. show_columns is the right list (rather than show_select_columns) because these are model properties, not database columns — the same place columns.type_generic lives.

Metric field values partly survived before because DatasourceEditor already re-parses metric.extra on mount; columns had no equivalent, so they came back undefined. That also meant a second save could write an empty extra back for columns, since buildExtraJsonObject() rebuilds extra from those now-missing fields — this fixes that too.

The change is purely additive to the show response. Feeding a show payload straight back into PUT was already unsupported (changed_on, created_on and type_generic are likewise read-only), so the round-trip tests were updated to strip the new fields alongside the existing ones.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: see the recording in #43279 — icons vanish immediately after Save and return after a page refresh.

After: icons and Certified values stay put after Save and after a dataset swap, with no refresh.

TESTING INSTRUCTIONS

Automated:

pytest tests/unit_tests/datasets/api_tests.py::test_get_dataset_exposes_certification_metadata
pytest tests/integration_tests/datasets/api_tests.py -k "update_dataset_create_column_and_metric or update_dataset_delete_column or update_dataset_update_column"

Manual:

  1. Pick a dataset with at least one metric, one physical column and one calculated column that have Certified by and/or Warning set, so the badges are visible in the chart source.
  2. Open a chart on that dataset in Explore.
  3. Click ... beside the dataset name → Edit dataset → Save, without changing anything.
  4. The Certified / Warning icons and the Certified field values remain visible for metrics, columns and calculated columns — no refresh needed.
  5. Repeat with a dataset swap instead of a save; the badges should survive that too.

ADDITIONAL INFORMATION

…taset

The dataset `show` endpoint exposed `columns.extra` and `metrics.extra` but
not the certification and warning attributes derived from them. Explore
rehydrates its datasource from that payload after a dataset is saved from the
"Edit dataset" modal or swapped from the chart source, so the certified and
warning badges — and the certified field values for columns and calculated
columns — disappeared until the page was reloaded, where the Explore bootstrap
serialization does include them.

Expose `is_certified`, `certified_by`, `certification_details` and
`warning_markdown` for both columns and metrics so the endpoint matches the
serialization Explore already expects.

Fixes apache#43279
@bito-code-review

bito-code-review Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #a13631

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • tests/unit_tests/datasets/api_tests.py - 1
Review Details
  • Files reviewed - 3 · Commit Range: bb45256..bb45256
    • superset/datasets/api.py
    • tests/integration_tests/datasets/api_tests.py
    • tests/unit_tests/datasets/api_tests.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

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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added api Related to the REST API change:frontend Requires changing the frontend explore Namespace | Anything related to Explore labels Aug 19, 2026
Comment thread superset/datasets/api.py
Comment on lines +285 to +292
"columns.certification_details",
"columns.certified_by",
"columns.is_certified",
"columns.warning_markdown",
"metrics.certification_details",
"metrics.certified_by",
"metrics.is_certified",
"metrics.warning_markdown",

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.

Suggestion: Each newly exposed certification property independently reparses the same serialized extra value, so every column and metric incurs up to four additional JSON parses during serialization. On wide datasets this adds avoidable CPU and latency to every show request; parse the metadata once and serialize the derived fields from the cached mapping or a single combined representation. [performance]

Severity Level: Minor 🧹
- ⚠️ Dataset show responses parse metadata repeatedly.
- ⚠️ Wide datasets incur additional serialization CPU.
- ⚠️ Large Explore datasource hydration may add latency.

Use CodeAnt Skill

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/datasets/api.py
**Line:** 285:292
**Comment:**
	*Performance: Each newly exposed certification property independently reparses the same serialized `extra` value, so every column and metric incurs up to four additional JSON parses during serialization. On wide datasets this adds avoidable CPU and latency to every `show` request; parse the metadata once and serialize the derived fields from the cached mapping or a single combined representation.

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
👍 | 👎

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch, fixed. Pushed a small cache on CertificationMixin.get_extra_dict() keyed off the raw extra string, so the four certification/warning properties share one json.loads per column/metric instead of reparsing each time, and it self-invalidates if extra is mutated on the instance (0a580f3).

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged performance issue is correct. The current implementation of the dataset API exposes certification and warning metadata by dynamically accessing model properties, which triggers repeated JSON parsing of the extra field for every column and metric during serialization.

To resolve this, you should parse the extra metadata once at the beginning of the serialization process and cache the resulting dictionary. You can then derive the certification and warning fields from this cached mapping for all columns and metrics, avoiding redundant parsing.

Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well?

@codecov

codecov Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.84%. Comparing base (097c99b) to head (0a580f3).
⚠️ Report is 215 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #43319       +/-   ##
===========================================
+ Coverage   66.67%   78.84%   +12.16%     
===========================================
  Files        2876     2878        +2     
  Lines      164007   165301     +1294     
  Branches    37834    38099      +265     
===========================================
+ Hits       109347   130324    +20977     
+ Misses      52514    32499    -20015     
- Partials     2146     2478      +332     
Flag Coverage Δ
hive 37.94% <75.00%> (-0.17%) ⬇️
mysql 57.67% <100.00%> (-0.09%) ⬇️
postgres 57.71% <100.00%> (-0.09%) ⬇️
presto 39.85% <100.00%> (-0.19%) ⬇️
python 83.74% <100.00%> (+24.56%) ⬆️
sqlite 57.39% <100.00%> (-0.04%) ⬇️
unit 73.96% <100.00%> (-26.04%) ⬇️

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.

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Taking a look into the bot review comments, but this is looking promising....

… JSON parsing

CertificationMixin.get_extra_dict() re-parses the serialized `extra`
JSON on every call. Since is_certified, certified_by,
certification_details, and warning_markdown are now all exposed on
the dataset show endpoint, serializing a single column/metric can
call get_extra_dict() up to four times. Cache the parsed dict on the
instance, keyed off the raw string it was parsed from, so it
self-invalidates whenever `extra` changes.

Addresses codeant-ai review feedback on apache#43319.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@netlify

netlify Bot commented Aug 28, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 0a580f3
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a9110e9a3bdad0008cc983a
😎 Deploy Preview https://deploy-preview-43319--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@rusackas rusackas added the merge-if-green If approved and tests are green, please go ahead and merge it for me label Aug 28, 2026
@bito-code-review

bito-code-review Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b3add6

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: bb45256..0a580f3
    • superset/models/helpers.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

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas merged commit b3f718d into apache:master Aug 28, 2026
77 checks passed
rusackas added a commit that referenced this pull request Aug 29, 2026
…taset (#43319)

Co-authored-by: rusackas <evan@rusackas.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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 change:frontend Requires changing the frontend explore Namespace | Anything related to Explore merge-if-green If approved and tests are green, please go ahead and merge it for me size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(explore): Edit Dataset save from Explore temporarily clears certified/warning icons and column Certified values until refresh

2 participants