Expand date formatters and add DATE_FORMAT function for better MySQL compatibility#46302
Expand date formatters and add DATE_FORMAT function for better MySQL compatibility#46302rschu1ze merged 1 commit intoClickHouse:masterfrom
DATE_FORMAT function for better MySQL compatibility#46302Conversation
|
@alexey-milovidov Hey! Sorry to bother you but I'm struggling with a particular test ( We are comparing a long timestamp based on metadata so it will never truly align as the metadata will always be behind a Full test failure log below: |
DATE_FORMAT function for better MySQL compatibility
rschu1ze
left a comment
There was a problem hiding this comment.
Thanks for this PR, I left a few comments but it looks overall good!
Kindly also update the docs (--> docs/en/sql-reference/functions/date-time-functions.md) with the new/changed substitutions and please add a hint about the new alias DATE_FORMAT.
src/Functions/formatDateTime.cpp
Outdated
There was a problem hiding this comment.
Semantics of "M" change (l. 983ff. on the left side) which technically makes this PR backwards-incompatible. This is okay but we should mark it as such - I'll add the right tags. It will then show up in the backward-incompatible section of the monthly changelog.
|
@JakeBamrah Consider to split this PR into two ... one PR with new substitutions (which I expect to pass the tests quickly) + another one with changed substitution "M". According to test results, there are still some memory corruption errors (e.g. in the AST Fuzzer) - would you like to check these? |
|
About the test failure in 00921_datetime64_compatibility_long: I see that you changed file tests/queries/0_stateless/00921_datetime64_compatibility_long.python ... it looks to me as if this is the cause for the failure. |
Hey @rschu1ze! Thank you very much for taking the time to review. I think splitting this change into two separate PRs (as you've suggested) would be the best approach to take. I'll have a go and see how I get on 😊 |
a5ae8d3 to
9f7643e
Compare
Most of the initial changes made for the first PR (aside from replacing |
|
(Not a big thing but once feedback / a review exists in a PR, it is more convenient to push fixes as separate commits so it is visible what was changed. That's not possible with force-pushing.) |
|
Adjusted the changelog entry ... semantics of "M" will be changed in a separate PR. |
Thanks for the heads up :) My intention was to keep the commit history tidy as a single commit but that's no big deal. I can push them as separate commits in future and squash before merge. |
|
Don't worry about the commit history, it is a mess already :) Complex PRs can also be integrated into the main branch by squashing them ... all intermediate steps will vanish then. |
Finally done it, all tests pass @rschu1ze. 🥳 Permission to get this change merged? |
|
Congrats to your first contribution to ClickHouse. May there be many more :) |
My first contribution ever haha! I'm actually so happy! Thanks so much for your help throughout. Would I be okay to start work on the |
|
Definitely. As long as the changelog and docs entries are good, nobody is going to complain. |

Fixes #46184
Changelog category:
Changelog entry:
formatDateTime()with substitutions "a", "b", "c", "h", "i", "k", "l" "r", "s", "W".Documentation entry for user-facing changes
User-readable short description:
DATE_FORMATis an alias offormatDateTime. Formats a Time according to the given Format string. Format is a constant expression, so you cannot have multiple formats for a single result column. (Provide link to formatDateTime)Motivation: Both
DATE_FORMATand the expanded date-formatter substitutions adhere more closely to MySQL standard behavior. Aligning clickhouse MySQL queries more closely with the MySQL standard will help users avoid unexpected MySQL date formatting behaviours.Example use:
SELECT DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s')