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
Add addDate
function for compatibility with MySQL
#54400
Conversation
This is an automated comment for commit e648646 with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page Successful checks
|
SELECT addDate('2022-05-07'::Date, INTERVAL 5 MINUTE); | ||
SELECT addDate('2022-05-07'::Date32, INTERVAL 5 MINUTE); | ||
SELECT addDate('2022-05-07'::DateTime, INTERVAL 5 MINUTE); | ||
SELECT addDate('2022-05-07'::DateTime64, INTERVAL 5 MINUTE); |
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.
Maybe test what happens if addition moves the result beyond the bounds of the date time type?
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.
The behavior will be the same as in the case with the +
or -
operations: 1900-01-01 00:00:00.000
with the required precision.
In MySQL we simply get NULL. Should we try to replicate this behavior?
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.
So, if the result is outside the bounds of the data type, we say that the result is undefined.
The same semantics is used in makeDate()
: https://fiddle.clickhouse.com/e58005b1-95f7-49fd-9989-10e295bfb82f
In my view, there is no need to replicate MySQL's behavior, it is more important to stay consistent within ClickHouse's functions and it's an edge case anyways.
5f05d0f
to
cf66271
Compare
tests/queries/0_stateless/02834_add_sub_date_functions.reference
Outdated
Show resolved
Hide resolved
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.
Lgtm, except the remaining small comments.
540b95b
to
fb683ee
Compare
fb683ee
to
e648646
Compare
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add
addDate
function for compatibility with MySQL andsubDate
for consistency. Reference #54275Documentation entry for user-facing changes