Skip to content

expression: Fix the issue that cast str as datetime with time_zone results in loss of precision#50958

Merged
ti-chi-bot[bot] merged 7 commits intopingcap:masterfrom
SeaRise:fix_issue_49555
Feb 6, 2024
Merged

expression: Fix the issue that cast str as datetime with time_zone results in loss of precision#50958
ti-chi-bot[bot] merged 7 commits intopingcap:masterfrom
SeaRise:fix_issue_49555

Conversation

@SeaRise
Copy link
Copy Markdown
Contributor

@SeaRise SeaRise commented Feb 4, 2024

What problem does this PR solve?

Issue Number: close #49555

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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 cast str as datetime with time_zone results in loss of precision

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/invalid-title do-not-merge/needs-tests-checked size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 4, 2024
@tiprow
Copy link
Copy Markdown

tiprow bot commented Feb 4, 2024

Hi @SeaRise. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

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 kubernetes/test-infra repository.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 4, 2024

Codecov Report

Merging #50958 (cd038bc) into master (9aabf72) will increase coverage by 2.3612%.
Report is 28 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #50958        +/-   ##
================================================
+ Coverage   70.5281%   72.8893%   +2.3612%     
================================================
  Files          1466       1467         +1     
  Lines        434112     439285      +5173     
================================================
+ Hits         306171     320192     +14021     
+ Misses       108699      99046      -9653     
- Partials      19242      20047       +805     
Flag Coverage Δ
integration 49.2309% <100.0000%> (?)
unit 70.4646% <100.0000%> (+0.1246%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 54.1120% <ø> (ø)
parser ∅ <ø> (∅)
br 51.3271% <ø> (+5.5585%) ⬆️

@SeaRise SeaRise changed the title Fix the issue that cast str as datetime with time_zone results in loss of precision expression: Fix the issue that cast str as datetime with time_zone results in loss of precision Feb 4, 2024
@SeaRise
Copy link
Copy Markdown
Contributor Author

SeaRise commented Feb 4, 2024

/cc @windtalker @Defined2014

Comment thread pkg/types/time_test.go Outdated
Comment thread pkg/types/time.go Outdated
index = -1
for i := end; i >= 0; i-- {
if unicode.IsPunct(rune(s[i])) {
if s[i] != '+' && s[i] != '-' && unicode.IsPunct(rune(s[i])) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have some functions in types/time.go and types/helper.go, like isValidSeparator and isPunctuation. Not sure could we directly use them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It looks like there is no function available.
BTW, I replace unicode.IsPunct by isPunctuation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, just a question more than suggestion.

Seems punctuation in different language has its own meaning. I think isPunctuation function is followed std::ispunct which may different with unicode.IsPunct. Not sure which one is correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As isPunctuation was used consistently in time.go, I have replaced it here. It seems that in time.go, either all function should use isPunctuation, or all instances should use unicode.IsPunct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe replacing it with isPunctuation is safe here, as this code snippet was introduced by #9933 to handle the case like 2019.01.01 00:00:00.

SeaRise and others added 2 commits February 5, 2024 10:52
Co-authored-by: Hangjie Mo <mohangjie1995@gmail.com>
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 5, 2024
Copy link
Copy Markdown
Contributor

@windtalker windtalker 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
Copy Markdown

ti-chi-bot bot commented Feb 6, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, windtalker

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [Defined2014,windtalker]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 6, 2024
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Feb 6, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-02-05 06:33:11.245770765 +0000 UTC m=+165716.812540655: ☑️ agreed by Defined2014.
  • 2024-02-06 02:34:51.431304427 +0000 UTC m=+237816.998074302: ☑️ agreed by windtalker.

@ti-chi-bot ti-chi-bot bot merged commit f0a26dd into pingcap:master Feb 6, 2024
@SeaRise SeaRise deleted the fix_issue_49555 branch February 6, 2024 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert a special datetime with time_zone results in loss of precision

3 participants