-
Notifications
You must be signed in to change notification settings - Fork 47
feat: New sort argument to rel_order()
#168
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
Conversation
krlmlr
left a comment
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.
Thanks, looks great! Triggering checks.
| OrderType order_type; | ||
| size_t i = 0; | ||
|
|
||
| for (expr_extptr_t expr : orders) { |
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.
@Antonov548: What's the idiomatic C++ way to iterate over two "parallel" vectors of the same length, orders and ascending ?
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.
As I know there is no specific function in STL to do this. Usually it's range based for loop with : for single iterable objects and index based loop for multiple vectors.
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.
Can we use zip_view() or similar?
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.
ranges require C++20 and higher. Not sure that it's worth of changing to C++20 if it's even possible.
|
Testing |
sort argument to rel_order()
c9d80cd to
be42107
Compare
|
Thanks! |
Related to tidyverse/duckplyr#92
Changes:
rapi_rel_ordernow accepts a vector of boolean values that describe whether each expression should be sorted in ascending orderrel_orderchecks that the number of expressions and boolean values match or defaults to TRUE if a null-value is passedrel_order(), notrapi_rel_order(). The tests break without this change as the default value is handled in rel_order.I will mark this as a draft due to these notes:
arrange(someotherfunction(desc(column)))in duckplyr. I don't know if this is an issue as the interpretation of such an expression in terms of sort order is a bit ambiguous(?).length(orders) == length(ascending). It is nowrel_order(),rapi_rel_order(). As a result, using rapi_rel_order directly might result indexing out of array bounds. Perhaps the check should be in rapi_rel_order as the vector is indexed there?rel_order()orrapi_rel_order? There are examples of both for other relation expressions