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

bug: DECIMAL type, the AVG() aggregate function return result set error #927

Open
2 of 3 tasks
davidshiz opened this issue Nov 14, 2022 · 3 comments
Open
2 of 3 tasks
Assignees
Labels
A-bug Something isn't working B-storage data type, data storage, insert,update,delete, transactions prio: high High priority

Comments

@davidshiz
Copy link
Collaborator

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

The wrong result is as follows:

mysql> select avg(d2) from cs1;
+----------------------+
| avg(d2)              |
+----------------------+
| 24031.61829363636200 |
+----------------------+
1 row in set (0.00 sec)

Expected behavior

the right answer is

mysql> select avg(d2) from cs1;
+----------------------+
| avg(d2)              |
+----------------------+
| 24031.61829363636364 |
+----------------------+
1 row in set (0.00 sec)

How To Reproduce

CREATE TABLE cs1 (d1 DECIMAL(17), d2 DECIMAL(17,10), d3 DECIMAL(17,16), d4 DECIMAL(17),d5 DECIMAL(17),i1 INT) ;

INSERT INTO cs1 VALUES
(1234,5678,-0.123456789012345,2,1,1),
(1234,-5678,0.12345678901234,2,1,1),
(1234567890123,123456.90123,0.12345678901234,2,1,1),
(NULL,NULL,NULL,2,1,1),
(0,0,0,2,1,1),
(1234,5678,0.123456789,3,2,2),
(-12345678923,-5678,0.1234567890121,3,2,2),
(56789012,123856.90,0.12345678909,3,2,2),
(NULL,NULL,NULL,3,2,2),
(0,0,0,3,2,2),
(1234,5678,-0.123456789012345,1111111111,1,1),
(1234,5678,-0.123456789012345,1111111111,1,1),
(1234,5678,-0.123456789012345,1111111112,1,1);

select avg(d2) from cs1;

Environment

root@localhost:/# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: d0c2e01b6
        Last commit time: Date:   Wed Nov 2 19:58:00 2022 +0800
        Build time: Date: Sun 06 Nov 2022 08:50:06 AM UTC
root@ub01:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@davidshiz davidshiz added the A-bug Something isn't working label Nov 14, 2022
@RingsC RingsC added the prio: high High priority label Nov 14, 2022
@adofsauron
Copy link
Collaborator

@duanfuxiang0 DECIMAL ? would you please have a look of DECIMAL ?

@davidshiz davidshiz changed the title bug: the AVG() aggregate function return result set error bug: DECIMAL type, the AVG() aggregate function return result set error Nov 21, 2022
@RingsC RingsC assigned hustjieke and unassigned adofsauron Nov 23, 2022
@RingsC
Copy link
Contributor

RingsC commented Nov 23, 2022

All issues about decimal can be fixed after the decimal type supported.

@wisehead wisehead added this to the stonedb_5.7_v1.0.3 milestone Jan 6, 2023
@wisehead wisehead added the B-storage data type, data storage, insert,update,delete, transactions label Jan 9, 2023
@hustjieke
Copy link
Collaborator

Related to #456 , to make the result correct, we need impl decimal128 to expand max precision to 38.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working B-storage data type, data storage, insert,update,delete, transactions prio: high High priority
Projects
None yet
Development

No branches or pull requests

5 participants