Skip to content

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

Open
s1ny1998 wants to merge 1 commit into
apache:masterfrom
s1ny1998:fix/explore-dataset-certification-rehydrate
Open

fix(explore): keep certification badges after saving or swapping a dataset#43319
s1ny1998 wants to merge 1 commit into
apache:masterfrom
s1ny1998:fix/explore-dataset-certification-rehydrate

Conversation

@s1ny1998

Copy link
Copy Markdown

SUMMARY

Saving a dataset from Explore (... beside the dataset name → Edit datasetSave), 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 extrais_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 datasetSave, 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
👍 | 👎

@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?

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

1 participant