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/2325 (#53129) #53207

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #53129

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>
Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>
Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>
@ti-chi-bot ti-chi-bot added 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. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR. labels May 13, 2024
@solotzg
Copy link
Contributor

solotzg commented May 13, 2024

@solotzg
Copy link
Contributor

solotzg commented May 13, 2024

/cc @XuHuaiyu @wshwsh12

@ti-chi-bot ti-chi-bot bot requested review from wshwsh12 and XuHuaiyu May 13, 2024 02:29
@solotzg
Copy link
Contributor

solotzg commented May 13, 2024

/test mysql-test

Copy link

ti-chi-bot bot commented May 13, 2024

@solotzg: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pull-br-integration-test
  • /test pull-lightning-integration-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/release-8.1/ghpr_build
  • pingcap/tidb/release-8.1/ghpr_check
  • pingcap/tidb/release-8.1/ghpr_check2
  • pingcap/tidb/release-8.1/ghpr_mysql_test
  • pingcap/tidb/release-8.1/ghpr_unit_test

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

Copy link

tiprow bot commented May 13, 2024

@solotzg: No presubmit jobs available for pingcap/tidb@release-8.1

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

solotzg commented May 13, 2024

/retest

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (release-8.1@a1c1451). Click here to learn what that means.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.1     #53207   +/-   ##
================================================
  Coverage               ?   71.1959%           
================================================
  Files                  ?       1465           
  Lines                  ?     421260           
  Branches               ?          0           
================================================
  Hits                   ?     299920           
  Misses                 ?     100901           
  Partials               ?      20439           
Flag Coverage Δ
unit 71.1959% <100.0000%> (?)

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

Components Coverage Δ
dumpling 53.9957% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 40.9738% <0.0000%> (?)

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

solotzg commented May 13, 2024

/retest

@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label May 13, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label May 13, 2024
Copy link

ti-chi-bot bot commented May 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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

@ti-chi-bot ti-chi-bot bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 13, 2024
Copy link

ti-chi-bot bot commented May 13, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-13 05:55:41.076494737 +0000 UTC m=+1459894.833630310: ☑️ agreed by wshwsh12.
  • 2024-05-13 06:00:24.984755758 +0000 UTC m=+1460178.741891328: ☑️ agreed by XuHuaiyu.

@solotzg
Copy link
Contributor

solotzg commented May 13, 2024

/retest

@ti-chi-bot ti-chi-bot bot merged commit 6b7a5ec into pingcap:release-8.1 May 13, 2024
18 checks passed
@solotzg solotzg deleted the cherry-pick-53129-to-release-8.1 branch May 13, 2024 06:46
ti-chi-bot bot pushed a commit that referenced this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm 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. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants