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(table-viz): rewrite with react-table and add query mode switch mode #10113

Merged
merged 7 commits into from Jun 29, 2020

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Jun 19, 2020

SUMMARY

This PR combines two major updates for the table chart:

  1. Replace its rendering from jquery.DataTables to react-table: feat(plugin-chart-table): rewrite with react-table apache-superset/superset-ui#623
  2. Rearrange the control panel, replace GROUP BY and NOT GROUP BY with a "Query Mode" switch: feat(legacy-table-chart): add query mode switch apache-superset/superset-ui#609 . It was not super clear what do GROUP BY and NOT GROUP BY mean and that they are mutually exclusive. Adding a tab switch should make things a little bit easier to understand.

In addition to these, there are also some smaller refactoring and UX improvements:

  1. Clean up the legacy backend API for TableViz, add support for a new query_mode field.
  2. Refactor control panel config management
  3. Change default customize options for table chart
    • Time format now defaults to smartDate, which formats the time column based on time grain
    • Page length now defaults to NULL, which automatically add pagination of 200 rows per page when number of cells > 10,000

Must wait for release of new versions of @superset-ui/chart-controls and @superset-ui/plugin-chart-table.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

After

TEST PLAN

Manual 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

superset/viz.py Show resolved Hide resolved
@ktmud ktmud force-pushed the table-control branch 3 times, most recently from 1b2eaac to ff486d1 Compare June 23, 2020 18:23
@ktmud ktmud marked this pull request as ready for review June 23, 2020 20:15
Copy link
Contributor

@kristw kristw left a comment

Choose a reason for hiding this comment

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

approve the js part

@ktmud ktmud force-pushed the table-control branch 5 times, most recently from c01fd1e to 0c4ac2b Compare June 24, 2020 02:23
Copy link
Member Author

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

@john-bodley @michellethomas would you mind having a look on the python part?

const validators = control.validators;
if (validators && validators.length > 0) {
const validatedControl = { ...control };
const validationErrors = [];
validators.forEach(f => {
const v = f(control.value);
const v = f.call(control, control.value, processedState);
Copy link
Member Author

Choose a reason for hiding this comment

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

Extend the validators API to allow access to processed state and the control config itself (not really in use anywhere yet).

@@ -344,26 +344,21 @@ def test_adhoc_filters_overwrite_legacy_filters(self):
self.assertEqual("(value3 in ('North America'))", query_obj["extras"]["where"])
self.assertEqual("", query_obj["extras"]["having"])

@patch("superset.viz.BaseViz.query_obj")
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why the patch is here, but removing it doesn't hurt.

with self.assertRaises(Exception):
test_viz = viz.TableViz(datasource, form_data)
Copy link
Member Author

Choose a reason for hiding this comment

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

The exception now raises earlier.

self.assertEqual(["colA", "colB", "__time__"], query_obj["metrics"])
self.assertEqual([("__time__", True)], query_obj["orderby"])
self.assertEqual(["colA", "colB", "sort_column"], query_obj["metrics"])
self.assertEqual([("sort_column", True)], query_obj["orderby"])
Copy link
Member Author

Choose a reason for hiding this comment

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

Rename so not to be confused with the time column (__timestamp).

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Quick first pass. We probably should add query_mode into QueryObject both here and on @superset-ui/query, and use that as the primary means of either grouping or not grouping a query. The plan in SIP-38 is to deprecate the groupby property and only use columns, and then perform grouping only if grouping is requested (we also hope to be introducing non-aggregating metrics soon)

superset/viz.py Outdated Show resolved Hide resolved
@ktmud
Copy link
Member Author

ktmud commented Jun 24, 2020

We probably should add query_mode into QueryObject both here and on @superset-ui/query

Do you mind if I do this in a separate PR?

@villebro
Copy link
Member

We probably should add query_mode into QueryObject both here and on @superset-ui/query

Do you mind if I do this in a separate PR?

@ktmud sure thing, just wanted to put the comments here to make sure I don't forget mentioning it. I can also do it, I have an idea of how we can do it with minimal disruption.

@ktmud ktmud force-pushed the table-control branch 5 times, most recently from d845c07 to c3b765f Compare June 24, 2020 18:41
@codecov-commenter
Copy link

codecov-commenter commented Jun 26, 2020

Codecov Report

Merging #10113 into master will decrease coverage by 0.16%.
The diff coverage is 98.21%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10113      +/-   ##
==========================================
- Coverage   70.57%   70.41%   -0.17%     
==========================================
  Files         594      594              
  Lines       31461    31483      +22     
  Branches     3228     3222       -6     
==========================================
- Hits        22205    22170      -35     
- Misses       9140     9198      +58     
+ Partials      116      115       -1     
Flag Coverage Δ
#cypress 52.80% <74.24%> (-0.77%) ⬇️
#javascript 59.42% <80.88%> (-0.19%) ⬇️
#python 70.40% <100.00%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
...et-frontend/src/explore/controlPanels/sections.jsx 100.00% <ø> (ø)
...uperset-frontend/src/views/chartList/ChartList.tsx 61.22% <ø> (ø)
...-frontend/src/visualizations/presets/MainPreset.js 100.00% <ø> (ø)
superset-frontend/src/welcome/DashboardTable.jsx 75.00% <ø> (ø)
superset-frontend/src/chart/ChartRenderer.jsx 78.37% <83.33%> (+0.11%) ⬆️
superset-frontend/src/explore/controlUtils.js 96.19% <96.42%> (-0.72%) ⬇️
...ontend/src/components/ListView/TableCollection.tsx 93.10% <100.00%> (ø)
...perset-frontend/src/explore/components/Control.jsx 100.00% <100.00%> (ø)
.../src/explore/components/ControlPanelsContainer.jsx 92.75% <100.00%> (+14.49%) ⬆️
...et-frontend/src/explore/reducers/exploreReducer.js 35.71% <100.00%> (+3.63%) ⬆️
... and 12 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 9de9e1c...d5ab573. Read the comment docs.

@ktmud
Copy link
Member Author

ktmud commented Jun 26, 2020

@ktmud I tried restarting this a few times, but it appears some unit tests are failing. Cypress seems to be fine, despite being red now (flaky test).

Rebased and fixed another issue with js-dom upgrade and now it seems fine?

@ktmud ktmud changed the title feat(viz): add query mode switch for table chart feat(viz): add query mode switch to table chart Jun 29, 2020
@ktmud ktmud merged commit 9bdfa05 into apache:master Jun 29, 2020
@ktmud ktmud deleted the table-control branch June 29, 2020 04:37
@ktmud ktmud changed the title feat(viz): add query mode switch to table chart feat(table-viz): rewrite with react-table and add query mode switch mode Jul 27, 2020
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
1, Replace table chart rendering from jquery.DataTables to react-table: apache-superset/superset-ui#623
2. Rearrange the control panel, replace GROUP BY and NOT GROUP BY with a "Query Mode" switch: apache-superset/superset-ui#609
@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/XL 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants