You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "trikker (via GitHub)" <gi...@apache.org> on 2024/01/09 07:20:42 UTC

[I] [Bug] sum of bigint column returns overflowed number but MySQL does not [doris]

trikker opened a new issue, #29715:
URL: https://github.com/apache/doris/issues/29715

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Version
   
   doris-2.0.4-rc02-e529646
   
   ### What's Wrong?
   
   doris :
   ```
   mysql> create table t2 (id int, num bigint) UNIQUE KEY(id) distributed by hash(id);
   Query OK, 0 rows affected (0.03 sec)
   
   mysql> insert into t2 values(1, 8442867910625079442);
   Query OK, 1 row affected (0.04 sec)
   {'label':'insert_34422d7d6ce44f88_b688f69da5d3e410', 'status':'VISIBLE', 'txnId':'16378678'}
   
   mysql> insert into t2 values(2, 5211348103418720126);
   Query OK, 1 row affected (0.04 sec)
   {'label':'insert_d6ae68853bf14511_9cca2e5f511b0a06', 'status':'VISIBLE', 'txnId':'16379094'}
   
   mysql> select sum(num) / 1024 / 1024 / 1024 from t2;
   +-----------------------------------------------------------------------------------------------------+
   | (((cast(sum(num) as DOUBLE) / cast(1024 as DOUBLE)) / cast(1024 as DOUBLE)) / cast(1024 as DOUBLE)) |
   +-----------------------------------------------------------------------------------------------------+
   |                                                                                 -4463389571.4448318 |
   +-----------------------------------------------------------------------------------------------------+
   1 row in set (0.03 sec)
   
   mysql> select sum(num) from t2;
   +----------------------+
   | sum(num)             |
   +----------------------+
   | -4792528059665752048 |
   +----------------------+
   1 row in set (0.02 sec)
   
   
   ```
   
   MySQL:
   ```
   mysql> use testdb
   Database changed
   mysql> create table t2 (id int auto_increment primary key, num bigint);
   Query OK, 0 rows affected (0.00 sec)
   
   mysql> insert into t2 values(1, 8442867910625079442);
   Query OK, 1 row affected (0.00 sec)
   
   mysql> insert into t2 values(2, 5211348103418720126);
   Query OK, 1 row affected (0.00 sec)
   
   mysql> select sum(num) / 1024 / 1024 / 1024 from t2;
   +-------------------------------+
   | sum(num) / 1024 / 1024 / 1024 |
   +-------------------------------+
   |      12716479612.555168166757 |
   +-------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select sum(num) from t2;
   +----------------------+
   | sum(num)             |
   +----------------------+
   | 13654216014043799568 |
   +----------------------+
   1 row in set (0.00 sec)
   
   ```
   
   ### What You Expected?
   
   In doris, the value is overflowed and should be negtive.
   
   ### How to Reproduce?
   
   See "What's Wrong"
   
   ### Anything Else?
   
   No
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [I] [Bug] sum of bigint column returns overflowed number but MySQL does not [doris]

Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on issue #29715:
URL: https://github.com/apache/doris/issues/29715#issuecomment-1884346737

   cannot do it as mysql.
   doris is a distributed database.
   so we need to decide expression's input and output type before execute this query to ensure all instance produce same type's data for one expression.
   in this stage, we could not see any data. so, we cannot determine whether the calculation overflows
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [I] [Bug] sum of bigint column returns overflowed number but MySQL does not [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #29715:
URL: https://github.com/apache/doris/issues/29715#issuecomment-3288994215

   We're closing this issue because it hasn't been updated in a while.
   If you'd like to revive this issue, please reopen it and feel free a maintainer to remove the Stale tag!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [I] [Bug] sum of bigint column returns overflowed number but MySQL does not [doris]

Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman closed issue #29715: [Bug] sum of bigint column returns overflowed number but MySQL does not
URL: https://github.com/apache/doris/issues/29715


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [I] [Bug] sum of bigint column returns overflowed number but MySQL does not [doris]

Posted by "LemonLiTree (via GitHub)" <gi...@apache.org>.
LemonLiTree commented on issue #29715:
URL: https://github.com/apache/doris/issues/29715#issuecomment-1882703185

   Need to manually cast(num as DECIMALV3(24, 2), We will optimize this issue


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org