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

   ### SUMMARY
   
   Dashboard dataset serialization calls `Slice.get_query_context()` for every 
chart only to collect query column names. Constructing each full `QueryContext` 
reloads its datasource and chart from the metadata database, causing N+1 
queries on dashboards with many charts.
   
   This change reads column names directly from the chart's serialized query 
context. It supports both the canonical `columns` key and the deprecated 
`groupby` key, and preserves the existing form-data fallback when a query 
context is absent or malformed.
   
   The regression test verifies that query-context columns are retained without 
calling `Slice.get_query_context()` or resolving the referenced datasource.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable; this is a backend performance change with no UI changes.
   
   ### TESTING INSTRUCTIONS
   
   1. Run the focused regression test:
      ```bash
      pytest -q tests/unit_tests/connectors/sqla/models_test.py -k 
data_for_slices_reads_serialized_query_context
      ```
      Expected: `2 passed`.
   2. Run pre-commit against the changed files:
      ```bash
      pre-commit run
      ```
      Expected: all applicable hooks pass, including MyPy, Ruff, and Pylint.
   
   The existing `data_for_slices` integration tests require an initialized test 
metadata database. In the local environment they stopped during fixture setup 
with `no such table: css_templates`, before reaching the tests.
   
   `pre-commit run --all-files` was also executed. All Python checks passed; 
unrelated frontend/docs/Helm hooks could not run because the local checkout 
does not have frontend dependencies, Yarn, or `helm-docs` installed.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] 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