to avoid (potential) arithmetic overflows (or at least reduce their likelyhood),
MonetDB uses the largest type for aggregation results and the next larger type of additions, e.g.:
sql>create table t (t tinyint, s smallint, i integer, b bigint, h hugeint);
operation successful (7.697ms)
sql>\fraw
sql>select sum(t) as t,sum(s) as s,sum(i) as i,sum(b) as b,sum(h) as h from t;
% sys.L4, sys.L7, sys.L12, sys.L15, sys.L20 # table_name
% t, s, i, b, h # name
% hugeint, hugeint, hugeint, bigint, hugeint # type
% 1, 1, 1, 1, 1 # length
[ NULL, NULL, NULL, NULL, NULL ]
sql>select t+t as tt,t+s as ts,t+i as ti,t+b as tb,t+h as th,s+s as ss,s+i as si,s+b as sb,s+h as sh,i+i as ii,i+b as ib,i+h as ih,b+b as bb,b+h as bh,h+h as hh from t;
% sys.L2, sys.L4, sys.L6, sys.L10, sys.L12, sys.L14, sys.L16, sys.L20, sys.L22, sys.L24, sys.L26, sys.L30, sys.L32, sys.L34, sys.L36 # table_name
% tt, ts, ti, tb, th, ss, si, sb, sh, ii, ib, ih, bb, bh, hh # name
% smallint, int, bigint, hugeint, hugeint, int, bigint, hugeint, hugeint, bigint, hugeint, hugeint, hugeint, hugeint, hugeint # type
% 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 # length
(in fact, there seems to be a bug for sum() on bigint,
returning bigint instead of hugeint ...)
----- On Jan 8, 2018, at 6:24 PM, Sreejith Sharma Sreejith.Sharma@harman.com wrote:
I see below issue is happening only if base column datatype is integer. All
other types working fine.
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| L3 |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 123456678 |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Other datatype like below
------------------+
| L3 |
------------------+
|123456678 |
------------------+
From: Sharma, Sreejith
Sent: Saturday, January 06, 2018 8:24 PM
To: users-list@monetdb.org
Subject: MonetDB - Column Header Question
All,
Quick question –
For a specific scenario I would like to understand below -
If we don’t specify column header in SQL or alias, how is MonetDB picks up the
column header? And what is the datatype for it? I saw it’s hge (scalar type) is
it so? Also, I would like to know where in source code it’s happening.
Example:
SELECT SUM(COLUMN_NAME) FROM TABLE_NAME;
------------------+
| L3 |
------------------+
|123456678 |
------------------+
Regards,
Sreejith
_______________________________________________
users-list mailing list
users-list@monetdb.org
https://clicktime.symantec.com/a/1/PUSMroFQGTIe5xmqwK1bK7dNDhEOs9Afw7aACjgLgNs=?d=7w45m9hGoMWcn4EPB9ZIelYBkDEgbqtxbQAsRA3u1tFkbPFe5rdMnu04MOKv6MxHy4AevQsUb0Huhves-oNaXPEpVfbBW4IdqQvcYytzlgkkTRY_tROSSs6zXEL8xbFNL0pTYiw9xUWXpkLKwf2Mbn58WmRGvSTe0yar9CkyexVnvCEacAQgOwksfTFnvv0ptxB3wzTYtcyY_R-Y0R34VyaUIQzqaHV6y0Lv55hnfsGSoPonILr6fC0fyrIOWOrKm8vOQVO6Y92VqwtkmJKEA4XOtn4KA99ekMQINVAKZTyDywm_niglE9-snV5CP88xT7S41yznHrI7K2L9iiyO3NG2Ja1tJtGj_R1UQLJRmJyNF9WUPQQoZcxPxfCDX3l_3NHMKLjq2Al0mc5UqJnmiv-dp3aV7PCfv-yGc3YH3Fc6r6s9XIbOTDTp9EU%3D&u=https%3A%2F%2Fwww.monetdb.org%2Fmailman%2Flistinfo%2Fusers-list
--
| Stefan.Manegold@CWI.nl | DB Architectures (DA) |
| www.CWI.nl/~manegold/ | Science Park 123 (L321) |
| +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________
users-list mailing list
users-list@monetdb.org
https://clicktime.symantec.com/a/1/PUSMroFQGTIe5xmqwK1bK7dNDhEOs9Afw7aACjgLgNs=?d=7w45m9hGoMWcn4EPB9ZIelYBkDEgbqtxbQAsRA3u1tFkbPFe5rdMnu04MOKv6MxHy4AevQsUb0Huhves-oNaXPEpVfbBW4IdqQvcYytzlgkkTRY_tROSSs6zXEL8xbFNL0pTYiw9xUWXpkLKwf2Mbn58WmRGvSTe0yar9CkyexVnvCEacAQgOwksfTFnvv0ptxB3wzTYtcyY_R-Y0R34VyaUIQzqaHV6y0Lv55hnfsGSoPonILr6fC0fyrIOWOrKm8vOQVO6Y92VqwtkmJKEA4XOtn4KA99ekMQINVAKZTyDywm_niglE9-snV5CP88xT7S41yznHrI7K2L9iiyO3NG2Ja1tJtGj_R1UQLJRmJyNF9WUPQQoZcxPxfCDX3l_3NHMKLjq2Al0mc5UqJnmiv-dp3aV7PCfv-yGc3YH3Fc6r6s9XIbOTDTp9EU%3D&u=https%3A%2F%2Fwww.monetdb.org%2Fmailman%2Flistinfo%2Fusers-list