Skip to content
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

expression: unify casting real to string in tidb (tikv#16975) | tidb-test=pr/2324 #53129

Merged
merged 4 commits into from May 11, 2024

Conversation

solotzg
Copy link
Contributor

@solotzg solotzg commented May 9, 2024

What problem does this PR solve?

Issue Number: close #51109

Problem Summary:

  • The default implementation about casting float32/float64 into string is supported by lib strconv. strconv use Ryu algorithm to calculate significant digits.
  • TiKV use method f32::to_string & f64::to_string to implement casting real to str. It can NOT guarantee precision if the number of significant digits exceeds the upper limit (f32: 6, f64: 15).
  • If don't use decimal exponent format, the size of target string might be too large.

What changed and how does it work?

Unify the behavior of converting real types to strings in tidb and tikv(tikv/tikv#16975).

  • use ryu lib in tikv to implement casting real type to str type.
  • if abs(num) >= 1e15 or abs(num) < 1e-15 then use decimal exponent format

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 incorrect result when casting REAL type to STRING type

Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 9, 2024
Copy link

tiprow bot commented May 9, 2024

Hi @solotzg. 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.

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-sigs/prow repository.

Copy link

codecov bot commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.8800%. Comparing base (ce74191) to head (5e6945f).
Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53129        +/-   ##
================================================
+ Coverage   72.4150%   73.8800%   +1.4649%     
================================================
  Files          1492       1492                
  Lines        429231     429258        +27     
================================================
+ Hits         310828     317136      +6308     
+ Misses        99123      92184      -6939     
- Partials      19280      19938       +658     
Flag Coverage Δ
integration 26.2688% <77.4193%> (?)
unit 71.2438% <100.0000%> (-0.0653%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 50.1840% <ø> (+8.7438%) ⬆️

1
Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>
@solotzg
Copy link
Contributor Author

solotzg commented May 9, 2024

/retest

Copy link

tiprow bot commented May 9, 2024

@solotzg: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

@solotzg
Copy link
Contributor Author

solotzg commented May 9, 2024

/test mysql-test

Copy link

tiprow bot commented May 9, 2024

@solotzg: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test mysql-test

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-sigs/prow repository.

@solotzg solotzg changed the title [WIP] expression: unify casting real to string in tidb expression: unify casting real to string in tidb | tidb-test=pr/2324 May 9, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 9, 2024
@solotzg
Copy link
Contributor Author

solotzg commented May 9, 2024

/retest

Copy link

tiprow bot commented May 9, 2024

@solotzg: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

@solotzg
Copy link
Contributor Author

solotzg commented May 9, 2024

/retest

Copy link

tiprow bot commented May 9, 2024

@solotzg: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

@solotzg
Copy link
Contributor Author

solotzg commented May 9, 2024

/cc @wshwsh12 @XuHuaiyu

@ti-chi-bot ti-chi-bot bot requested review from wshwsh12 and XuHuaiyu May 9, 2024 14:15
2
Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>
Copy link

ti-chi-bot bot commented May 10, 2024

@gengliqi: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

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.

@solotzg solotzg changed the title expression: unify casting real to string in tidb | tidb-test=pr/2324 expression: unify casting real to string in tidb (tikv#16975) | tidb-test=pr/2324 May 11, 2024
Copy link

ti-chi-bot bot commented May 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gengliqi, wshwsh12, XuHuaiyu

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

The pull request process is described here

Needs approval from an approver in each of these files:

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

Copy link

ti-chi-bot bot commented May 11, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-11 09:22:54.058931214 +0000 UTC m=+1299527.816066789: ☑️ agreed by XuHuaiyu.
  • 2024-05-11 09:24:33.870458489 +0000 UTC m=+1299627.627594061: ☑️ agreed by wshwsh12.

@solotzg
Copy link
Contributor Author

solotzg commented May 11, 2024

/test mysql-test

Copy link

tiprow bot commented May 11, 2024

@solotzg: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test mysql-test

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-sigs/prow repository.

@solotzg
Copy link
Contributor Author

solotzg commented May 13, 2024

/cherrypick release-8.1

@ti-chi-bot
Copy link
Member

@solotzg: new pull request created to branch release-8.1: #53207.

In response to this:

/cherrypick release-8.1

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 bot pushed a commit that referenced this pull request May 13, 2024
solotzg added a commit to solotzg/tidb that referenced this pull request May 14, 2024
ti-chi-bot bot pushed a commit that referenced this pull request May 14, 2024
terry1purcell pushed a commit to terry1purcell/tidb that referenced this pull request May 17, 2024
RidRisR pushed a commit to RidRisR/tidb that referenced this pull request May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query with distinct gets a unexpected result
5 participants