maropu commented on issue #25347: [SPARK-28610][SQL] Allow having a decimal buffer for long sum URL: https://github.com/apache/spark/pull/25347#issuecomment-518430889 Is this common handling for long sum in DBMSs? In postgresql and mysql, it seems that the output type is decimal and the answer is correct; ``` // PostgreSQL postgres=# \d t Table "public.t" Column | Type | Collation | Nullable | Default --------+--------+-----------+----------+--------- l | bigint | | | postgres=# select * from t; l --------------------- 9223372036854775807 1 (2 rows) postgres=# select sum(l) from t; sum --------------------- 9223372036854775808 (1 row) postgres=# create temporary table v as select sum(l) from t; postgres=# \d v Table "pg_temp_3.v" Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- sum | numeric | | | // MySQL mysql> explain t; +-------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+------+-----+---------+-------+ | l | bigint(20) | YES | | NULL | | +-------+------------+------+-----+---------+-------+ 1 row in set (0.00 sec) mysql> select * from t; +---------------------+ | l | +---------------------+ | 9223372036854775807 | | 1 | +---------------------+ 2 rows in set (0.00 sec) mysql> select sum(l) from t; +---------------------+ | sum(l) | +---------------------+ | 9223372036854775808 | +---------------------+ 1 row in set (0.00 sec) mysql> create temporary table v as select sum(l) from t; mysql> explain v; +--------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------------+------+-----+---------+-------+ | sum(l) | decimal(41,0) | YES | | NULL | NULL | +--------+---------------+------+-----+---------+-------+ 1 row in set (0.01 sec) ```
---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
