betodealmeida opened a new pull request #15827: URL: https://github.com/apache/superset/pull/15827
### SUMMARY <!--- Describe the change below, including rationale and design decisions --> This PR adds a new API for retrieving data associated with a saved chart via a `GET` request. The API uses the stored `query_context` (https://github.com/apache/superset/pull/15824) to run the query and fetch the data. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> N/A ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> I accessed the endpoint manually by hitting http://localhost:9000/api/v1/chart/56/data/: ```json { "result": [ { "cache_key": "bf6383e65e2d57b646778b8b0bbb875b", "cached_dttm": null, "cache_timeout": 86400, "annotation_data": {}, "error": null, "is_cached": false, "query": "SELECT gender AS gender,\n SUM(num) AS sum__num\nFROM birth_names\nWHERE ds >= TO_TIMESTAMP('1900-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US')\n AND ds < TO_TIMESTAMP('2000-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US')\nGROUP BY gender\nORDER BY sum__num DESC\nLIMIT 50000", "status": "success", "stacktrace": null, "rowcount": 2, "colnames": [ "gender", "sum__num" ], "coltypes": [ 1, 0 ], "data": [ { "gender": "boy", "sum__num": 40276116 }, { "gender": "girl", "sum__num": 28055783 } ], "applied_filters": [], "rejected_filters": [] } ] } ``` And http://localhost:9000/api/v1/chart/56/data/?format=csv: ```csv gender,sum__num boy,40276116 girl,28055783 ``` I also added unit tests. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] 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 - [x] 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]
