You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/07/21 22:52:25 UTC

[GitHub] [superset] betodealmeida opened a new pull request #15827: feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API

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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] edited a comment on pull request #15827: feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #15827:
URL: https://github.com/apache/superset/pull/15827#issuecomment-884571781


   # [Codecov](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#15827](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (22e1b3d) into [master](https://codecov.io/gh/apache/superset/commit/9a79a5775bcf0742678a890a02dc4abb1f057032?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9a79a57) will **increase** coverage by `0.00%`.
   > The diff coverage is `81.39%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/15827/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@           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           
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | mysql | `81.53% <81.39%> (-0.01%)` | :arrow_down: |
   | postgres | `81.56% <81.39%> (-0.01%)` | :arrow_down: |
   | python | `81.65% <81.39%> (-0.01%)` | :arrow_down: |
   | sqlite | `81.19% <81.39%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/charts/api.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY2hhcnRzL2FwaS5weQ==) | `86.17% <81.39%> (-0.63%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [9a79a57...22e1b3d](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] betodealmeida commented on a change in pull request #15827: feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API

Posted by GitBox <gi...@apache.org>.
betodealmeida commented on a change in pull request #15827:
URL: https://github.com/apache/superset/pull/15827#discussion_r674408247



##########
File path: tests/integration_tests/charts/api_tests.py
##########
@@ -1049,12 +1052,89 @@ def test_chart_data_simple(self):
         """
         self.login(username="admin")
         request_payload = get_query_context("birth_names")
-        rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
+        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)

Review comment:
       Ugh, thanks! :)




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a change in pull request #15827: feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API

Posted by GitBox <gi...@apache.org>.
eschutho commented on a change in pull request #15827:
URL: https://github.com/apache/superset/pull/15827#discussion_r674404656



##########
File path: tests/integration_tests/charts/api_tests.py
##########
@@ -1049,12 +1052,89 @@ def test_chart_data_simple(self):
         """
         self.login(username="admin")
         request_payload = get_query_context("birth_names")
-        rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
+        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)

Review comment:
       debug?




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] betodealmeida merged pull request #15827: feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API

Posted by GitBox <gi...@apache.org>.
betodealmeida merged pull request #15827:
URL: https://github.com/apache/superset/pull/15827


   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #15827: feat: add `GET /api/v1/chart/{chart_id}/data/?format{format}` API

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on pull request #15827:
URL: https://github.com/apache/superset/pull/15827#issuecomment-884571781


   # [Codecov](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#15827](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (22e1b3d) into [master](https://codecov.io/gh/apache/superset/commit/9a79a5775bcf0742678a890a02dc4abb1f057032?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9a79a57) will **decrease** coverage by `0.01%`.
   > The diff coverage is `81.39%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/15827/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #15827      +/-   ##
   ==========================================
   - Coverage   76.90%   76.88%   -0.02%     
   ==========================================
     Files         984      984              
     Lines       51670    51658      -12     
     Branches     6991     6991              
   ==========================================
   - Hits        39736    39719      -17     
   - Misses      11710    11715       +5     
     Partials      224      224              
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | mysql | `81.53% <81.39%> (-0.01%)` | :arrow_down: |
   | postgres | `81.53% <81.39%> (-0.03%)` | :arrow_down: |
   | python | `81.62% <81.39%> (-0.03%)` | :arrow_down: |
   | sqlite | `81.19% <81.39%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/charts/api.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY2hhcnRzL2FwaS5weQ==) | `86.17% <81.39%> (-0.63%)` | :arrow_down: |
   | [superset/models/dashboard.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvbW9kZWxzL2Rhc2hib2FyZC5weQ==) | `74.77% <0.00%> (-2.22%)` | :arrow_down: |
   | [superset/common/query\_context.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29tbW9uL3F1ZXJ5X2NvbnRleHQucHk=) | `81.42% <0.00%> (-0.40%)` | :arrow_down: |
   | [superset/utils/decorators.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGVjb3JhdG9ycy5weQ==) | `92.59% <0.00%> (-0.27%)` | :arrow_down: |
   | [superset/utils/cache.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvY2FjaGUucHk=) | `74.28% <0.00%> (-0.25%)` | :arrow_down: |
   | [superset/reports/notifications/base.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvcmVwb3J0cy9ub3RpZmljYXRpb25zL2Jhc2UucHk=) | `95.23% <0.00%> (-0.22%)` | :arrow_down: |
   | [superset/utils/log.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvbG9nLnB5) | `92.95% <0.00%> (-0.15%)` | :arrow_down: |
   | [superset/migrations/shared/security\_converge.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvbWlncmF0aW9ucy9zaGFyZWQvc2VjdXJpdHlfY29udmVyZ2UucHk=) | `86.82% <0.00%> (-0.11%)` | :arrow_down: |
   | [superset/initialization/\_\_init\_\_.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvaW5pdGlhbGl6YXRpb24vX19pbml0X18ucHk=) | `87.82% <0.00%> (-0.09%)` | :arrow_down: |
   | [superset/connectors/sqla/models.py](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29ubmVjdG9ycy9zcWxhL21vZGVscy5weQ==) | `88.30% <0.00%> (-0.02%)` | :arrow_down: |
   | ... and [4 more](https://codecov.io/gh/apache/superset/pull/15827/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [9a79a57...22e1b3d](https://codecov.io/gh/apache/superset/pull/15827?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org