Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expand new chart data endpoint coverage #9903

Merged
merged 11 commits into from Jun 2, 2020

Conversation

villebro
Copy link
Member

@villebro villebro commented May 25, 2020

SUMMARY

Currently only the legacy chart data endpoint is supported for the following operations:

  • View Query
  • View Raw Results
  • View Samples
  • Export CSV

This PR hides the legacy/non-legacy chart data request logic behind a single function
getChartDataRequest, which determines whether the legacy /superset/explore_json or new /api/v1/chart/data endpoint should be used, and adds support for requesting samples, raw json results, CSV and SQL Query to QueryContext.

TEST PLAN

CI + local testing

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-commenter
Copy link

codecov-commenter commented May 25, 2020

Codecov Report

Merging #9903 into master will increase coverage by 0.01%.
The diff coverage is 89.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9903      +/-   ##
==========================================
+ Coverage   71.35%   71.37%   +0.01%     
==========================================
  Files         585      585              
  Lines       30889    30913      +24     
  Branches     3227     3246      +19     
==========================================
+ Hits        22041    22063      +22     
- Misses       8739     8741       +2     
  Partials      109      109              
Flag Coverage Δ
#cypress 54.06% <67.30%> (+0.06%) ⬆️
#javascript 59.39% <69.23%> (-0.02%) ⬇️
#python 71.54% <100.00%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
superset-frontend/src/explore/exploreUtils.js 81.65% <ø> (-1.39%) ⬇️
superset/charts/schemas.py 100.00% <ø> (ø)
superset/viz.py 71.97% <ø> (ø)
...tend/src/explore/components/DisplayQueryButton.jsx 76.31% <80.00%> (+6.98%) ⬆️
superset-frontend/src/chart/chartAction.js 61.82% <84.78%> (+2.31%) ⬆️
...nd/src/explore/components/ExploreActionButtons.jsx 100.00% <100.00%> (ø)
superset/common/query_context.py 79.61% <100.00%> (+0.13%) ⬆️
superset/config.py 89.71% <100.00%> (+0.04%) ⬆️
superset/utils/core.py 89.18% <100.00%> (+0.01%) ⬆️
superset/views/core.py 76.58% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5324e25...4e48e6f. Read the comment docs.

@villebro villebro force-pushed the villebro/csv-chart-data branch 4 times, most recently from 3784018 to 3b01cac Compare May 27, 2020 14:48
@villebro villebro requested a review from rusackas June 1, 2020 14:21
@villebro villebro changed the title feat: Implement chart data ep for DisplayQueryButton feat: Implement chart data endpoint for additional components Jun 1, 2020
@villebro villebro changed the title feat: Implement chart data endpoint for additional components feat: expand new chart data endpoint coverage Jun 1, 2020
@@ -109,6 +109,7 @@ def _try_json_readsha(filepath, length): # pylint: disable=unused-argument

ROW_LIMIT = 50000
VIZ_ROW_LIMIT = 10000
SAMPLES_ROW_LIMIT = 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use a comment here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

dashboardId,
requestParams,
)
: v1ChartDataRequest(formData, force, requestParams);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set up legacyChartDataRequest and v1ChartDataRequest to have different function signatures on purpose. I think it's better to keep v1ChartDataRequest simpler rather than conforming to a legacy set of parameters.

Feel free to keep the change if you prefer. Just wanted to state my original intent there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.. The original reason I harmonized the signatures is that the new request function ended up requiring additional parameters that were in line with the legacy request (force and requestParams), so I ended up throwing method in there to make the signatures equal. But you're completely right that there's really no reason why they need to be equal, and going forward I anticipate the next version will probably not be backwards compatible with this request. So I'll either drop method from the new request or add a comment to explain that they've been made equal for convenience purposes only, and that it isn't strictly required.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your assessment @suddjian , no point in making the signatures identical. I dropped method from v1ChartDataRequest to make sure we don't unnecessarily hang on to legacy constructs in the codebase.

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTGM! (with a couple comments)

// new API returns an object with an array of restults
// problem: json holds a list of results, when before we were just getting one result.
// problem: response holds a list of results, when before we were just getting one result.
// `queryResponse` state is used all over the place.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoud this queryResponse be changed to chartDataResponse to keep things in step?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! 👍

@villebro villebro merged commit 38a6bd7 into apache:master Jun 2, 2020
@villebro villebro deleted the villebro/csv-chart-data branch June 2, 2020 07:47
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* feat: implement new chart API for additional components

* Fix python tests

* Fix tests

* Fix lint

* fix camel case error in requestParams

* lint

* fix samples row limit

* Add samples row limit to config

* remove unnecessary code

* lint

* Address review comments
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants