feat: add GET /api/v1/chart/{chart_id}/data/?format{format} API#15827
Merged
betodealmeida merged 2 commits intoapache:masterfrom Jul 22, 2021
Merged
feat: add GET /api/v1/chart/{chart_id}/data/?format{format} API#15827betodealmeida merged 2 commits intoapache:masterfrom
GET /api/v1/chart/{chart_id}/data/?format{format} API#15827betodealmeida merged 2 commits intoapache:masterfrom
Conversation
420ecef to
221ec86
Compare
eschutho
reviewed
Jul 21, 2021
| rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "post_data") | ||
| self.assertEqual(rv.status_code, 200) | ||
| data = json.loads(rv.data.decode("utf-8")) | ||
| print(data) |
eschutho
approved these changes
Jul 21, 2021
Member
eschutho
left a comment
There was a problem hiding this comment.
LGTM pending one small debug leftover
Codecov Report
@@ Coverage Diff @@
## master #15827 +/- ##
=======================================
Coverage 76.90% 76.90%
=======================================
Files 984 984
Lines 51670 51698 +28
Branches 6991 6991
=======================================
+ Hits 39736 39758 +22
- Misses 11710 11716 +6
Partials 224 224
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This was referenced Jul 22, 2021
This was referenced Jul 23, 2021
cccs-RyanS
pushed a commit
to CybercentreCanada/superset
that referenced
this pull request
Dec 17, 2021
…ache#15827) * feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API * Fix test
QAlexBall
pushed a commit
to QAlexBall/superset
that referenced
this pull request
Dec 29, 2021
…ache#15827) * feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API * Fix test
|
I need this data paginated. It's possible? |
cccs-rc
pushed a commit
to CybercentreCanada/superset
that referenced
this pull request
Mar 6, 2024
…ache#15827) * feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API * Fix test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
This PR adds a new API for retrieving data associated with a saved chart via a
GETrequest.The API uses the stored
query_context(#15824) to run the query and fetch the data.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
I accessed the endpoint manually by hitting http://localhost:9000/api/v1/chart/56/data/:
{ "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:
I also added unit tests covering the case where
query_contextis null, and the case where it's present and data is returned.ADDITIONAL INFORMATION