Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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): Floating numbers not sorting correctly in result column #17573
fix(sqllab): Floating numbers not sorting correctly in result column #17573
Changes from 2 commits
a57cf70
43742de
580f9d9
628a549
8be6346
4904ef1
d1d0751
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
if you're using localeCompare with the numeric option, then do you still need to convert to a float? It looks like you're converting to a float and then back again to a string? It seems redundant.
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.
Also, nice find on localeCompare, but I don't think it's going to support multilingually unless you explicitly pass the language that you want to support as the second argument.
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 need to parse the floating numbers for them to sort correctly, but
localeCompare
will only take strings. The numerical option allows it to check the strings for numbers.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.
@lyndsiWilliams but when you do
String(aValue)
andString(bValue)
you're converting them back to strings. It should work if you just calllocaleCompare
on the values withoutparseFloat
, assuming you pass thenumeric
option: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 did a lot of playing around with this and figured out that the sorting works without
localeCompare
so I removed it and added testing inthis commit
. While testing I found any floating point number that had more than 2 floating points (like12.001
or longer) is astring
, while any other number is anumber
. I think originally, the floating numbers weren't sorting correctly because the types were mixed. Just using theparseFloatingNums
function seems to solve this so maybe we can look at usinglocaleCompare
in the future for multilingual sorting, since it just seems to be causing issues in this instance. I also didn't realize you had to explicitly pass the language you want to support as a second argument, so I don't think I'll be able to make this work withlocaleCompare
.