-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
fix(sqllab): perf regression on #21532 refactor #21632
fix(sqllab): perf regression on #21532 refactor #21632
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21632 +/- ##
==========================================
- Coverage 65.55% 65.54% -0.01%
==========================================
Files 1798 1799 +1
Lines 68793 68814 +21
Branches 7326 7332 +6
==========================================
+ Hits 45095 45106 +11
- Misses 21823 21828 +5
- Partials 1875 1880 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
LGTM! Good fix to prevent re-rendering AceEditorWrapper. |
afb6c4d
to
0d6638e
Compare
cb4100b
to
b8d18f2
Compare
const middlewares = [thunk]; | ||
const mockStore = configureStore(middlewares); | ||
|
||
describe('useQueryEditor', () => { |
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.
Can you avoid nesting? You can just use test
for each test case in the file.
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.
sure
import { shallowEqual, useSelector } from 'react-redux'; | ||
import { SqlLabRootState, QueryEditor } from 'src/SqlLab/types'; | ||
|
||
export default function useQueryEditor<T extends keyof QueryEditor>( |
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 love this hook! Great improvement to code readability.
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, work as expected. One suggestion for this part is that should disable the Run
button when the selection area is 1) empty or 2) beginning a comment(--) of SQL and only 1 line.
selection.in.SQLLab.mov
- set disable for comments only
@zhaoyongjie I made changes for this improvement run.selection.mov |
Thanks for tackling the long-term UX issue! |
SUMMARY
This commit fixes the rendering perf regression from #21532
Since SqlLab consists of heavy rendering components, accessing the entire current queryEditor object can occur re-rendering on unnecessary children components.
https://github.com/apache/superset/pull/21532/files#diff-dac1ba995e65dfae7c9aa7a0a794036ace1eb83814e2101d354752da2bb41dfdR166-R172
This commit removes the
currentQueryEditor
selector and moved into AceEditorWrapper where the actual values are consumed.This commit also introduces
useQueryEditor
hook which supports a syntax validation that helps to optimize the queryEditor value access.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
type.validation.mov
TESTING INSTRUCTIONS
npm run test
ADDITIONAL INFORMATION
cc: @EugeneTorap @zhaoyongjie