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

unexpected result: casting real to string #16974

Closed
solotzg opened this issue May 9, 2024 · 0 comments · Fixed by #16975 or #17013
Closed

unexpected result: casting real to string #16974

solotzg opened this issue May 9, 2024 · 0 comments · Fixed by #16975 or #17013

Comments

@solotzg
Copy link
Contributor

solotzg commented May 9, 2024

Bug Report

What version of TiKV are you using?

5.4 ~ master

What operating system and CPU are you using?

Steps to reproduce

ref pingcap/tidb#51109

CREATE TABLE `t` (
  `c` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
INSERT INTO `t` VALUES(4474.7812);
set tidb_opt_projection_push_down=1;
select c, cast(c as char) from t;

What did you expect?

mysql> select c, cast(c as char) from t;
+-----------+-----------------+
| c         | cast(c as char) |
+-----------+-----------------+
| 4474.7812 | 4474.7812       |
+-----------+-----------------+
1 row in set (0.00 sec)

What did happened?

mysql> select c, cast(c as char) from t;
+-----------+-----------------+
| c         | cast(c as char) |
+-----------+-----------------+
| 4474.7812 | 4474.7813       |
+-----------+-----------------+
1 row in set (0.00 sec)
@solotzg solotzg added the type/bug Type: Issue - Confirmed a bug label May 9, 2024
ti-chi-bot bot pushed a commit that referenced this issue May 11, 2024
close #16974

expression: fix casting REAL type to STRING type
- unify the behavior of converting real types to strings in tidb#53129 and tikv.
- use ryu lib in tikv to implement casting real type to str type.
- `if abs(num) >= 1e15 or (num is not zero and abs(num) < 1e-15)` then use decimal exponent format

Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>
ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this issue May 11, 2024
close tikv#16974

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this issue May 13, 2024
close #16974

expression: fix casting REAL type to STRING type
- unify the behavior of converting real types to strings in tidb#53129 and tikv.
- use ryu lib in tikv to implement casting real type to str type.
- `if abs(num) >= 1e15 or (num is not zero and abs(num) < 1e-15)` then use decimal exponent format

Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>

Co-authored-by: TONG, Zhigao <tongzhigao@pingcap.com>
ti-chi-bot bot pushed a commit that referenced this issue May 14, 2024
close #16974

Signed-off-by: TONG, Zhigao <tongzhigao@pingcap.com>
ti-chi-bot bot added a commit that referenced this issue May 22, 2024
close #16974

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants