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

fix: Allows X-Axis Sort By for custom SQL #30393

Merged

Conversation

michael-s-molina
Copy link
Member

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

  • 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

@dosubot dosubot bot added the explore:control Related to the controls panel of Explore label Sep 25, 2024
@michael-s-molina michael-s-molina added the v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch label Sep 25, 2024
Copy link
Member

@villebro villebro 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 an optional extra task to break out this into a dedicated util and add 100 % coverage for it (yay!)

Comment on lines 70 to 79
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),
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Niiice! ❤️

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Michael cleans up utils faster than this guy! 🚀
image

@michael-s-molina michael-s-molina merged commit abf2943 into apache:master Sep 25, 2024
34 of 35 checks passed
sadpandajoe pushed a commit that referenced this pull request Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
explore:control Related to the controls panel of Explore packages size/L v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants