Basic math operations with SUM() - unexpected values

we had this problem: updated version of MariaDB Columnstore from 1.2.2 to 1.2.4 and nonsense started.

We have these columns `col1, col2` both are `DECIMAL(15,3)` there was already working query to calculate these two columns (see alias `A`) and this wasn't calculating right when `col2` had zero sum - after db update. Alias `B` was first approach which didn't help. And `C` was solution for proper working.

I want to know explanation why this happened and what caused this behaviour.

``````SELECT
id,
SUM(col1) AS c1,
SUM(col2) AS c2,
SUM(col1 - col2) AS A,
SUM(CAST(col1 AS DOUBLE) - CAST(col2 AS DOUBLE)) AS B,
SUM(CAST(col1 AS DECIMAL(15,3)) - CAST(col2 AS DECIMAL(15,3))) AS C
FROM table GROUP BY id
``````

1.2.2:

``````+----+----------+--------+-----------+
| id |    c1    |   c2   |     A     |
+----+----------+--------+-----------+
|  1 | 1199.940 |  0.000 |  1199.940 |
|  2 |  979.860 | 69.990 |   909.870 |
+----+----------+--------+-----------+
``````

1.2.4 with extra SUMs

``````+----+----------+--------+-----------------------+---------+-----------+
| id |    c1    |   c2   |           A           |    B    |     C     |
+----+----------+--------+-----------------------+---------+-----------+
|  1 | 1199.940 |  0.000 | -9223372036853575.868 |       0 |  1199.940 |
|  2 |  979.860 | 69.990 |               909.870 |  909.87 |   909.870 |
+----+----------+--------+-----------------------+---------+-----------+
``````