-
Notifications
You must be signed in to change notification settings - Fork 605
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
feat(api): add .delta
method for computing difference in units between two temporal values
#7273
Conversation
173bcae
to
ab64b4c
Compare
Clouds are passing
|
Just to show that the clouds are running the relevant tests successfully:
|
WUT Adding this one to the "SQL is everywhere" talk |
This whole operation replaces The temporal delta is a juicier example because there are multiple correct ways to implement 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.
This looks good to me -- one (non-blocking) question about the usage of _
in docstrings
@gforsyth I don't see your comment! |
This PR adds a new API to temporal types,
delta
, that allows users to computethe difference between two temporal types (times, dates, and timestamps).
This implemented for all the backends for which it was relatively
straightforward to get matching behavior out of.
Backends differ in many annoying and meaningful ways in how they implement this
operation:
datediff
(MS SQL),date_diff
(DuckDB)for each type:
date_diff
(DuckDB, MS SQL, etc) vstime_diff
,date_diff
, timestamp_diff (BigQuery)order, DuckDB subtracts the first argument from the second argument)
'day'
(ClickHouse) vsDAY
(MySQL)or truncates afterward. (Trino and MySQL truncate after, others before)
Tests hit each of these cases.
Backends that support one or more of these operations:
Notably, postgres and oracle do not have functions for computing the delta between two temporal types in integer units.
Closes #7195