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

chore(sqllab): Remove schemaOptions from redux store #23257

Merged

Conversation

justinpark
Copy link
Member

SUMMARY

As a followup step of the react-query migration (#21240), this commit migrates the schemaOptions state from redux to react-query to reduce the complexity of the queryEditor state.
(The schemaOptions state only used in the editor for autocomplete so useQuery is a lighter way to share the state)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

  • After:

Screenshot 2023-03-01 at 11 55 04 AM

Screenshot 2023-03-01 at 12 02 48 PM

  • Before:

Notification_Center

Screenshot 2023-03-01 at 12 04 40 PM

TESTING INSTRUCTIONS

Go to sqllab and select a database to get the associated schemas
Type some part of the schema name on the editor and check the autocomplete including the fetched schemas

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

cc: @ktmud

@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Merging #23257 (e2b55f9) into master (d16eda6) will increase coverage by 1.76%.
The diff coverage is 45.45%.

❗ Current head e2b55f9 differs from pull request most recent head 4d0f3d7. Consider uploading reports for the commit 4d0f3d7 to get more accurate results

@@            Coverage Diff             @@
##           master   #23257      +/-   ##
==========================================
+ Coverage   65.74%   67.51%   +1.76%     
==========================================
  Files        1907     1907              
  Lines       73431    73429       -2     
  Branches     7973     7975       +2     
==========================================
+ Hits        48280    49576    +1296     
+ Misses      23103    21803    -1300     
- Partials     2048     2050       +2     
Flag Coverage Δ
javascript 53.76% <57.14%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset-frontend/src/SqlLab/actions/sqlLab.js 63.86% <ø> (-0.19%) ⬇️
...frontend/src/SqlLab/components/SaveQuery/index.tsx 75.55% <ø> (ø)
...d/src/SqlLab/components/SqlEditorLeftBar/index.tsx 54.28% <ø> (-0.51%) ⬇️
superset-frontend/src/SqlLab/fixtures.ts 100.00% <ø> (ø)
superset-frontend/src/SqlLab/reducers/sqlLab.js 37.07% <ø> (+0.20%) ⬆️
superset-frontend/src/SqlLab/types.ts 57.14% <ø> (ø)
...frontend/src/components/DatabaseSelector/index.tsx 91.52% <ø> (-0.15%) ⬇️
...et-frontend/src/components/TableSelector/index.tsx 79.22% <ø> (ø)
superset-frontend/src/dashboard/actions/hydrate.js 2.08% <ø> (+0.02%) ⬆️
...src/dashboard/components/DashboardBuilder/state.ts 70.37% <ø> (-2.05%) ⬇️
... and 96 more

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

Copy link
Member

@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.

LGTM with just one tiny question

})),
}),
[schemaOptions],
);
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need a useMemo here? It may look cleaner to keep the words logic with other autocomplete words.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. useMemo will reduce the cost of schemaWords mapping from schemaOptions.
(For example, airbnb has > 10,000 schema options so useMemo should be needed)

@michael-s-molina
Copy link
Member

Hi @justinpark @ktmud. We have ongoing discussions to update Redux to the latest version which could potentially introduce a conflict with react-query given that Redux RTK is in the same domain space. Maybe it would be a good idea to discuss this in a SIP before moving forward?

@justinpark
Copy link
Member Author

@michael-s-molina glad to hear that there's moving forward to redux-toolkit and plan to introduce the Redux RTK.
Since both (RTK Query and react-query) are similar technology and the core approach which uses a dedicated hook to get the api state without the existing complex redux state path, it won't be hard to migrate from react-query hook to RTK hooks.
The main issue is the timing. When will be RTK will be integrated?
If RTK integration is under discussion and need some months to have, this can be a major blocker of our plan.
As I said the migration from redux-query to RTK query is not a big problem (and we can re-use current api hooks without updating specs), I'm going with react-query now (as a part of legacy redux digest work. and this requires same work for RTK query integration). I will also drive the RTK query migration once RTK is landed.

@michael-s-molina
Copy link
Member

@justinpark We have been discussing that our current Redux version precedes Redux Toolkit which makes the developer experience way more complex than it needs to be. Our plan was to upgrade Redux to the latest version as the first step to start organizing the Redux state, which would already help with new code. Can you help us migrate Redux to the new version to continue your improvements using RTK instead of React Query? If not, we can talk with @john-bodley and maybe I can help with the upgrade.

@justinpark
Copy link
Member Author

justinpark commented Mar 20, 2023

@michael-s-molina If we've already decided to move on RTK, i'm happy to change React query by RTK.
Let me create new PR for it.

@michael-s-molina
Copy link
Member

@michael-s-molina If we've already decided to move on RTK, i'm happy to change React query by RTK. Let me create new PR for it.

Nice! Thank you for the improvement.

@rusackas rusackas merged commit ca4dd26 into apache:master Mar 22, 2023
@michael-s-molina
Copy link
Member

@rusackas I'm not sure if @justinpark was planning to merge this PR given that he's working on the RTK alternative. @justinpark should we revert or it's ok?

@rusackas
Copy link
Member

Oops, was on a roll merging mergeable things. Sorry if I got a little trigger happy.

@justinpark
Copy link
Member Author

@michael-s-molina this should be okay since I'm tracking of react-query migration by rdk-query.
I can include this updates too.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 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 size/M 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants