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(explore): Don't discard controls with custom sql when changing datasource #20934

Merged
merged 5 commits into from
Oct 19, 2022

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Aug 1, 2022

SUMMARY

Currently, when user changes datasource in Explore, we try to keep controls that use columns available in the new datasource, but we always discard adhoc columns/metrics/filters that use custom SQL. This PR changes that behaviour by always keeping the controls with custom sql, but with added warning icon. We can't reliably verify if controls with custom SQL are compatible with the new datasource, so we let the user decide (since it's quicker to remove a control than to create it from scratch). If user runs a successful query, the warning icons disappear.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen.Recording.2022-08-01.at.16.07.53.mov

TESTING INSTRUCTIONS

  1. Add some controls with custom sql
  2. Switch to a different datasource
  3. Verify that the controls with custom sql now have a warning icon with a tooltip
  4. If the next query is successful, the warning icons should disappear. Otherwise, they should still be displayed

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

Super nit. The rest of the code LGTM. I would like to have some manual testing once CI passes

if (
typeof value === 'object' &&
isDefined(value) &&
'datasourceWarning' in value
Copy link
Member

Choose a reason for hiding this comment

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

Minor. Do you think we can have Typescript helping here or maybe setting it in a constant? I am not very fond of using a plain string for datasourceWarning

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately the typing of that area of code is very poor and value's type is basically any object, so addind datasourceWarning to typing here would require a lot of restructuring which is not a focus of this PR.
However, I think 'fieldName' in objectName is a rather common pattern, we use it in many places in the code, including typescript files

Copy link
Member Author

@kgabryje kgabryje Oct 17, 2022

Choose a reason for hiding this comment

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

To be precise, there are 21 occurences across 9 typescript files of this pattern 🙂

@kgabryje kgabryje force-pushed the feat/dont-discard-adhoc branch from bf02406 to 1cb86c9 Compare October 16, 2022 07:22
@kgabryje
Copy link
Member Author

@jinghua-qa May I ask for help with testing?

@kgabryje
Copy link
Member Author

/testenv up

@codecov
Copy link

codecov bot commented Oct 17, 2022

Codecov Report

Merging #20934 (8eb5335) into master (6f2e76b) will decrease coverage by 0.02%.
The diff coverage is 62.06%.

@@            Coverage Diff             @@
##           master   #20934      +/-   ##
==========================================
- Coverage   66.89%   66.87%   -0.03%     
==========================================
  Files        1805     1805              
  Lines       69071    69056      -15     
  Branches     7369     7364       -5     
==========================================
- Hits        46208    46180      -28     
- Misses      20956    20966      +10     
- Partials     1907     1910       +3     
Flag Coverage Δ
javascript 53.23% <62.06%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ackages/superset-ui-core/src/query/types/Column.ts 100.00% <ø> (ø)
...d/packages/superset-ui-core/src/utils/isDefined.ts 100.00% <ø> (ø)
.../explore/components/ExploreViewContainer/index.jsx 53.00% <ø> (ø)
...ls/DndColumnSelectControl/DndAdhocFilterOption.tsx 50.00% <0.00%> (-50.00%) ⬇️
.../controls/DndColumnSelectControl/OptionWrapper.tsx 65.85% <ø> (ø)
...nents/controls/MetricControl/AdhocMetricOption.jsx 77.77% <ø> (ø)
...s/controls/MetricControl/MetricDefinitionValue.jsx 100.00% <ø> (ø)
...plore/components/controls/OptionControls/index.tsx 77.17% <0.00%> (-0.85%) ⬇️
...et-frontend/src/explore/reducers/exploreReducer.js 38.09% <0.00%> (+0.59%) ⬆️
...ontrols/DndColumnSelectControl/DndColumnSelect.tsx 43.85% <33.33%> (+4.15%) ⬆️
... and 23 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link
Contributor

@kgabryje Ephemeral environment spinning up at http://34.217.90.254:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@jinghua-qa jinghua-qa left a comment

Choose a reason for hiding this comment

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

Validate the issue is fixed. LGTM

@kgabryje kgabryje merged commit cddc361 into apache:master Oct 19, 2022
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 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 need:qa-review Requires QA review size/L 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants