-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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(explore): export csv data pivoted for Pivot Table [ID-9] #17512
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17512 +/- ##
========================================
Coverage 68.57% 68.57%
========================================
Files 1588 1596 +8
Lines 64947 65214 +267
Branches 6963 6949 -14
========================================
+ Hits 44537 44721 +184
- Misses 18520 18610 +90
+ Partials 1890 1883 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
1515eb5
to
3c413d2
Compare
/testenv up |
@kgabryje Ephemeral environment spinning up at http://52.39.232.35:8080. Credentials are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small comments, but this works and looks great! It would be nice if we could add a few tests:
- Ensure that a query context with
form_data
validates successfully - Add tests for
ExportToCSVDropdown
that ensures it renders correctly with standard/pivoted options + the children.
superset-frontend/src/explore/components/ExploreActionButtons.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/explore/components/ExploreActionButtons.tsx
Outdated
Show resolved
Hide resolved
superset/charts/data/api.py
Outdated
@@ -221,6 +221,7 @@ def data(self) -> Response: | |||
if json_body is None: | |||
return self.response_400(message=_("Request is not JSON")) | |||
|
|||
form_data = json_body.pop("form_data", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to pop here? Can't we just do
form_data = json_body.pop("form_data", None) | |
form_data = json_body.get("form_data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need form_data in json_body. We pass it as a separate argument
Added tests for |
After some discussion, I implemented Ville's suggestions. We already had schema validations tests in place, so I just added form_data to query context generator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few last comments
@@ -158,6 +163,7 @@ export interface QueryContext { | |||
/** Response format */ | |||
result_format: string; | |||
queries: QueryObject[]; | |||
form_data: QueryFormData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be optional, as it is in the python code?
form_data?: QueryFormData;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
superset/charts/schemas.py
Outdated
@@ -1157,6 +1157,8 @@ class ChartDataQueryContextSchema(Schema): | |||
result_type = EnumField(ChartDataResultType, by_value=True) | |||
result_format = EnumField(ChartDataResultFormat, by_value=True) | |||
|
|||
form_data = fields.Raw() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add allow_none=True
and required=False
here, as we probably want to support explicitly passing a null
value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
1353297
to
e924b14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for this great improvement!
Ephemeral environment shutdown and build artifacts deleted. |
SUMMARY
Apply pivot table post processing to data downloaded as CSV in Pivot Table V2 chart. The CSV data will have pivoted format (see the difference on screenshots).
When on Pivot Table chart, the .CSV button is replaced by a dropdown containing 2 options - Original and Pivoted. Clicking the latter triggers download of pivoted data.
On all other charts, the CSV button works just like before.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Example pivot table:
Before:
After:
TESTING INSTRUCTIONS
Create a pivot table chart, click on download as csv icon. A dropdown with 2 options should open - Original and Pivoted.
Clicking Original should download a CSV file formatted like the one on the "Before" screenshot.
Clicking Pivoted should download a CSV file formatted like the one on the "After" screenshot
The CSV button on any other chart should work like before - begin download immediately instead of opening a dropdown menu.
ADDITIONAL INFORMATION
CC @junlincc