Skip to content

expression: fix the issue that extracting day_microsecond/day_second/day_minute/day_hour from Time type emits wrong result#36297

Merged
ti-chi-bot merged 8 commits intopingcap:masterfrom
zanmato1984:fix-34998
Jul 19, 2022
Merged

expression: fix the issue that extracting day_microsecond/day_second/day_minute/day_hour from Time type emits wrong result#36297
ti-chi-bot merged 8 commits intopingcap:masterfrom
zanmato1984:fix-34998

Conversation

@zanmato1984
Copy link
Contributor

@zanmato1984 zanmato1984 commented Jul 19, 2022

What problem does this PR solve?

Issue Number: close #34998

Problem Summary:

There was once an issue #9716 about extract(day_microsecond) not recognizing the heading day portion, and it was later fixed by #21601. But that PR introduced another problem about extract(day_microsecond) on regular time data. What happens under the hood is:

  1. Unit day_microsecond guides the type infer to interpret the time data as datetime through implicit cast;
  2. When doing implicit cast from time to datetime, current timestamp is padded to the original time as the date portion of the resulting datetime value;
  3. The time portion is messed up with the newly padded date portion, esp. for values larger than 24 hour or negative.

What is changed and how it works?

For regular datetime/timestamp/time types, let extract(day_microsecond/second/minute/hour) interpret it as time.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Fix the issue that extracting day_microsecond/day_second/day_minute/day_hour from time type emits wrong result.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • SeaRise
  • XuHuaiyu

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Details

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-cherry-pick-release-5.0 needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-6.0 needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 19, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jul 19, 2022

@zanmato1984
Copy link
Contributor Author

/run-check_dev_2

1 similar comment
@zanmato1984
Copy link
Contributor Author

/run-check_dev_2

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 19, 2022
@XuHuaiyu XuHuaiyu added the type/bugfix This PR fixes a bug. label Jul 19, 2022
Copy link
Contributor

@solotzg solotzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-chi-bot
Copy link
Member

@solotzg: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

Details

In response to this:

lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 19, 2022
@zanmato1984
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

DetailsCommit hash: ccded3a

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 19, 2022
@ti-chi-bot ti-chi-bot merged commit 51b8884 into pingcap:master Jul 19, 2022
@zanmato1984 zanmato1984 deleted the fix-34998 branch July 19, 2022 11:07
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 19, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #36333

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 19, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #36335

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 19, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #36336

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 19, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.3 in PR #36337

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 19, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.4 in PR #36338

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 19, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-6.0 in PR #36339

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 19, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-6.1 in PR #36340

@sre-bot
Copy link
Contributor

sre-bot commented Jul 19, 2022

TiDB MergeCI notify

🔴 Bad News! [1] CI still failing after this pr merged.
These failed integration tests don't seem to be introduced by the current PR.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-common-test 🔴 failed 1, success 10, total 11 37 min Existing failure
idc-jenkins-ci/integration-cdc-test 🟢 all 36 tests passed 37 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 12 tests passed 13 min Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 8 min 49 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 6 min 47 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 6 min 3 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 5 min 45 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 40 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 20 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-cherry-pick-release-5.0 needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract day_microsecond from time column

8 participants