expression: refine date_add/sub return type and precision (#35009) #35444
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.
cherry-pick #35009 to release-5.0
You can switch your code base to this Pull Request by using git-extras:
# In tidb repo: git pr https://github.com/pingcap/tidb/pull/35444
After apply modifications, you can push your change to this PR via:
What problem does this PR solve?
Issue Number: close #31799, close #9813. And part of #31867 will be resolved by this PR.
Problem Summary:
There exists several issues about function
date_add
anddate_sub
:date_add/sub(int/double/decimal, interval)
: MySQL returns string, TiDB returns datetime.date_add/sub(duration, interval)
when interval unit contains YMD part (except for DAY_MICROSECOND - I believe it's a mismatch between MySQL's actual behavior and its document, but it doesn't matter much), MySQL returns datetime with current date padded, TiDB returns time.--column-type-info
is your good friend.Honestly I can file 10+ bugs easily about the above issues.
What is changed and how it works?
Don't get scared of this huge PR - 90% are tests and 80% of which are generated, the core is quite simple. This PR includes the following changes:
expression/builtin_time.go
:date_add
anddate_sub
.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.