calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jinfeng Ni <jinfengn...@gmail.com>
Subject Re: sum of integer overflow
Date Fri, 07 Aug 2015 17:38:16 GMT
I think it makes sense to use bigint as the result type for sum(integer).

Postgres seems to work in this way.

mydb=# \d+ emp
                                  Table "public.emp"
  Column  |         Type          | Modifiers | Storage  | Stats target |
Description
----------+-----------------------+-----------+----------+--------------+-------------
 empno    | integer               |           | plain    |              |
.....

create table tmp as select sum(empno) sum_eno from emp;

\d+ tmp;
                         Table "public.tmp"
 Column  |  Type  | Modifiers | Storage | Stats target | Description
---------+--------+-----------+---------+--------------+-------------
 sum_eno | bigint |           | plain   |              |


As we can see, the column sum_eno in 'tmp' table after the CTAS statement
has bigint type.

In Drill, we also use bigint for sum(integer).  Drill has to put additional
logic, since Calcite by default will use int as the result type for
sum(int).




On Fri, Aug 7, 2015 at 6:51 AM, hongbin ma <mahongbin@apache.org> wrote:

> hi,
>
> Suppose I have a table column called "price", its data type is integer.
> it seems that the sum aggregator in "select sum(price) from table" will
> return integer type, too.
>
> When I have millions of rows in the table,
> "select sum(price) from table" might overflow, is it a bug?
> Or may I how do you look into this problem?
>
> --
> Regards,
>
> *Bin Mahone | 马洪宾*
> Apache Kylin: http://kylin.io
> Github: https://github.com/binmahone
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message