-
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: Allows X-Axis Sort By for custom SQL #30393
fix: Allows X-Axis Sort By for custom SQL #30393
Conversation
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 with an optional extra task to break out this into a dedicated util and add 100 % coverage for it (yay!)
const xAxisValue = controls?.x_axis?.value as QueryFormColumn; | ||
// Given that we don't know the type of a custom SQL column, | ||
// we treat it as sortable and give the responsibility to the | ||
// user to provide a sortable result. | ||
const isCustomSQL = !isPhysicalColumn(xAxisValue); | ||
return ( | ||
isForcedCategorical(controls) || | ||
isCustomSQL || | ||
checkColumnType( | ||
getColumnLabel(controls?.x_axis?.value as QueryFormColumn), | ||
getColumnLabel(xAxisValue), |
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 was wondering why this was passing our 100 % coverage check, but it turns out this file is tsx
which is ignored in the check. I'm thinking at some point we should really move this type of critical non-React logic into .ts
files and start adding tests for them. For this specific function, I'd maybe move it under src/shared-controls/utils/isSortable.ts
and then add a test for it.
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.
@villebro I extracted the function and added tests.
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.
Niiice! ❤️
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.
(cherry picked from commit abf2943)
SUMMARY
This PR fixes an issue where the X-Axis Sort By control was disappearing when a custom SQL was being used as an x-axis. Given that we currently have no way to identify the result type of a custom SQL, we make the control available and give the responsibility to the user to provide a sortable result. We implement the same behavior for the Time Grain control as you can see in the recordings.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2024-09-25.at.15.33.41.mov
Screen.Recording.2024-09-25.at.16.19.55.mov
TESTING INSTRUCTIONS
Check the videos for instructions.
ADDITIONAL INFORMATION