s1ny1998 opened a new pull request, #43319:
URL: https://github.com/apache/superset/pull/43319

   ### 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:
   
   ```bash
   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
   
   - [x] Has associated issue: Fixes #43279
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to