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
Extend range window queries to non-timestamp order-by columns #7675
Extend range window queries to non-timestamp order-by columns #7675
Changes from 3 commits
97866a6
65f2572
24aa1f3
255d7c4
0bbc207
194b525
a776935
dfc4518
ab6ca8b
ff5e271
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.
This seems inconsistent. Seems like the timestamp interval should also be the same type. There's no loss of information in converting a lower resolution timestamp value to a higher resolution, yes? E.g., if the orderby column is seconds, and the internal is
[-1, +1]
days, then that's no different than[-86400, +86400]
seconds.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 haven't grasped your point, I think.
The order-by column is the timestamp at a certain resolution. The window bounds are durations (with matching or lower resolution). The bounds can't be timestamps because they are relative intervals. (E.g. 7 days preceding, 86400 seconds following.)
The old API took
size_type
and interpreted them in days (I.e. lowest resolution).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.
Right, I meant the resolution should be the same, not the exact type. Otherwise you need a double dispatch.
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.
You're right; I'm doing the double-dispatch in this version of things. (By the way, is host-side dispatch expensive? My understanding is that the dispatch itself isn't more expensive than an
if
check. The real cost is in the casting.)The reason this is permitted is to support how Spark/SQL specifies intervals at different resolutions. Would you recommend having the caller cast appropriately instead?
(The same will likely apply for decimals.)
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.
It's not really expensive in runtime, but can be quite expensive in compile time/binary size depending on the amount of code in the leaves of the double dispatched code paths.
Yes, the way I see it, it doesn't seem any different from how Pandas/Spark allow joining on columns of different types but libcudf doesn't support this. The caller is expected to perform any casting beforehand.
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.
Hmm... That'd certainly simplify certain other aspects of this feature.
Let me try pulling out the scaling part.
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.
Hey, Jake. If the scaling feature is removed, I'd still need to check that the window-duration and the orderby-timstamps are of the same resolution.
I don't know how I'd do that without doing a double dispatch, short of long if-else.
Would you be averse to the double dispatch in this case?
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.
Ok, it took me a while to realize what should have been obvious to me: The scaling functionality is pre-existing. :/
The
grouped_time_range...()
function already permitted timestamp columns in any resolution, accepted the window widths indays
, and scaled it to the timetamp's resolution. All thatscale_to()
does is to move the scaling logic intorange_window_bounds
.Removing
range_window_bounds::scale_to()
would break existing functionality ingrouped_time_range...()
, and callers thereof (including Spark) who depend on the window widths being inDAYS
.For what it's worth, there isn't a way to avoid the double-dispatch anyway, even without
scale_to()
, because we'd still have to validate that the window range type (integral
orduration
) are compatible with the order-by column (integral
ortimestamp
). This is currently checked as part of thescale_to
call stack.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.
Why are these r-value refs? What if someone wants to reuse the same
range_window_bounds
for multiple calls togrouped_range_rolling_window
?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.
This had to do with the ownership of the range scalar in
range_window_bounds
. I'll see if this can be removed ifscale_to
is removed.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 think this should be the user's responsibility. Otherwise it's very inconsistent both with itself (you can't do the same thing with non-time types?) and with other libcudf APIs that require types already be matched.
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.
My thought was that scaling would also apply to decimal types, when we add support for it.
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.
We don't rescale decimal types in other APIs either. Decimal types with different scales are treated like different types.