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

[Windowing] Handle multiple sort expressions #142

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

ohaibbq
Copy link
Contributor

@ohaibbq ohaibbq commented Jan 29, 2024

Closes #140

@codecov-commenter
Copy link

Codecov Report

Merging #142 (de18a0c) into main (7d3a82f) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #142      +/-   ##
==========================================
- Coverage   45.82%   45.81%   -0.01%     
==========================================
  Files          47       47              
  Lines       17800    17801       +1     
==========================================
- Hits         8156     8155       -1     
- Misses       8182     8189       +7     
+ Partials     1462     1457       -5     

return false
}
cond, _ := sortedValues[i].OrderBy[orderBy].Value.LT(sortedValues[j].OrderBy[orderBy].Value)
sort.Slice(sortedValues, func(i, j int) bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should share this implementation with function_aggregate.go

Copy link
Owner

Choose a reason for hiding this comment

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

sort.SliceStable not available here ? ( https://pkg.go.dev/sort#SliceStable )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use a stable sort, I don't think it'd make any difference.

The previous implementation was re-sorting the entire list for each ORDER BY expression that was provided. The new implementation maintains sort order within each group.

i.e. 2024-02-01 dt group in the test below has its rows sorted by letter when the dt fields are equal.

Copy link
Owner

Choose a reason for hiding this comment

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

OK, It's good. thank you.

@goccy
Copy link
Owner

goccy commented Jan 30, 2024

Thank you for your contribution !! LGTM 👍

@goccy goccy merged commit 5edd42c into goccy:main Jan 30, 2024
6 checks passed
@ohaibbq ohaibbq deleted the dan/window-multiple-sort branch March 28, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windowing] ORDER BY gives priority to proceeding clauses
3 participants