-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
refactor(sqllab): Remove tableOptions from redux state #23488
refactor(sqllab): Remove tableOptions from redux state #23488
Conversation
Codecov Report
@@ Coverage Diff @@
## master #23488 +/- ##
==========================================
+ Coverage 68.08% 68.10% +0.02%
==========================================
Files 1920 1920
Lines 73984 73978 -6
Branches 8092 8092
==========================================
+ Hits 50374 50385 +11
+ Misses 21539 21518 -21
- Partials 2071 2075 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@michael-s-molina could you help the code review? |
Hi @justinpark! What are plans long term for redux here? Are you looking to remove it completely and replace it with react-query or just for select places? I know for a while now we've had state in both redux and in hooks, and haven't ever come to a decision on where frontend state should reside. |
@eschutho As I state in #21240, the long term plan is replacing existing api related state (queries, tables, validationResult and functionNames in queryEditors) in redux store to a hook based state (using react-query was the first proposal and finally it will migrate to redux toolkit query (which is a similar solution of react-query) once #23460 landed.). Redux will be remained the editor's state(queryEditors, tabHistory, alerts, unsavedQueryEditor) that is only made by the user inputs. The benefit of this redux cleanup work is
Please let me know if you have any concerns with this redux cleanup work |
@justinpark @eschutho I would like to add my 2 cents about the topic. The motivation for using react-query/RTK Query is the following (copied from RTK website):
Originally @justinpark was planning to use react-query to manage data fetching and caching. Given that RTK has a tool in the same domain called RTK Query, I advised to use that instead to preserve library compatibility.
RTK Query is built on top of Redux as you can see in another quote from the same RTK website:
What RTK Query does is to automatically generate the actions, reducers, slices, and hooks to manage data fetching and caching. So it's a complement to Redux, not a replacement. @justinpark volunteered to convert existing @justinpark I would advise to complete some steps before further modifying existing Redux state:
Lastly, thank you so much @justinpark for driving this effort. It's a really nice improvement, long overdue, that will really simplify our use of Redux and introduce many quality checks during development. |
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.
Given that @justinpark will remove the dependency of react-query
in a follow-up, this PR LGTM as the API will remain pretty similar.
@justinpark Maybe this tool can help us generate the API given that we use OpenAPI. |
12f21f5
to
eab204a
Compare
I will take a look compatibility with fab API |
SUMMARY
Similar to #23257, this commit migrates the tableOptions state from redux to react-query to reduce the complexity of the queryEditor state.
(The tableOptions 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:
Before:
TESTING INSTRUCTIONS
Go to sqllab and select a database to get the associated schemas
Type some part of the table name on the editor and check the autocomplete including the fetched schemas
ADDITIONAL INFORMATION