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 incorrect keying of by= results involving functions of keys #6708

Merged
merged 7 commits into from
Jan 17, 2025

Conversation

MichaelChirico
Copy link
Member

Closes #5583.

In principal this could be a breaking change for some user that has by = .(a = foo(a)) where a is the key and foo() is weakly increasing.

If we find any such case in revdeps, I will bump this change to 1.18.0 (there is a known workaround for the bug, i.e. use keyby=, and the bug appears to have taken quite some time to surface) and push the breaking change in next release. As a breaking change, the fix is also trivial (switch to keyby=).

Copy link

codecov bot commented Jan 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.62%. Comparing base (d782232) to head (bb5e0c5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6708   +/-   ##
=======================================
  Coverage   98.62%   98.62%           
=======================================
  Files          79       79           
  Lines       14631    14642   +11     
=======================================
+ Hits        14430    14441   +11     
  Misses        201      201           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jan 4, 2025

Comparison Plot

Generated via commit 3177ed1

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 4 minutes and 30 seconds
Installing different package versions 8 minutes and 21 seconds
Running and plotting the test cases 2 minutes and 20 seconds

@MichaelChirico MichaelChirico requested a review from tdhock January 17, 2025 17:03
Copy link
Member

@tdhock tdhock left a comment

Choose a reason for hiding this comment

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

lgtm

i had no idea this was an issue.

there are so many special cases!

# For #5583, we also ensure there are no function calls in by (which might break sortedness)
if (is.name(bysub)) return(TRUE)
if (identical(bysub[[1L]], quote(list))) bysub = bysub[-1L]
if (length(all.names(bysub)) > length(byvars)) return(FALSE)
Copy link
Member

Choose a reason for hiding this comment

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

nice refactor and helper function name!

@MichaelChirico MichaelChirico merged commit 6641ca0 into master Jan 17, 2025
8 of 9 checks passed
@MichaelChirico MichaelChirico deleted the by-rev-key branch January 17, 2025 22:55
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.

Using a function inside by causes troubles
2 participants