[MCOL-4615] GROUP_CONCAT() precision loss for huge narrow decimal Created: 2021-03-16  Updated: 2021-04-09  Resolved: 2021-04-09

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 5.5.1, 5.6.1, 6.1.1
Fix Version/s: 6.1.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MCOL-4361 Replace pow(10.0, (double)scale) expr... Closed
Relates
relates to MCOL-4660 Narow decimal to string conversion is... Closed
Sprint: 2021-5, 2021-6

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(17,1)) ENGINE=ColumnStore;
INSERT INTO t1 VALUES (-8999999999999999.9);
SELECT GROUP_CONCAT(a) FROM t1;

+---------------------+
| GROUP_CONCAT(a)     |
+---------------------+
| -9000000000000000.0 |
+---------------------+

Looks wrong. The expected result is '-8999999999999999.9'.

This happens because the underlying printing code in GroupConcator::outputRow() uses double representation.
It should be fixed to print DECIMAL natively.



 Comments   
Comment by Alexander Barkov [ 2021-03-17 ]

Update:

The patch for MCOL-4361 improves the results slightly by using `long double` instead of `double`.

However, the code still needs to be changed to use native TDecimal64 printing.

Comment by Gagan Goel (Inactive) [ 2021-04-06 ]

For QA: Instructions to reproduce the issue and verify the fix works are in the issue description.

Comment by Daniel Lee (Inactive) [ 2021-04-09 ]

Build verified: 6.1.1 ( Drone #2104 )

Reproduced the issue in 5.5.2-1 and verified fixed in 6.1.1

MariaDB [mytest]> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected, 1 warning (0.054 sec)
 
MariaDB [mytest]> CREATE TABLE t1 (a DECIMAL(17,1)) ENGINE=ColumnStore;
Query OK, 0 rows affected (0.136 sec)
 
MariaDB [mytest]> INSERT INTO t1 VALUES (-8999999999999999.9);
Query OK, 1 row affected (0.108 sec)
 
MariaDB [mytest]> SELECT GROUP_CONCAT(a) FROM t1;
+---------------------+
| GROUP_CONCAT(a)     |
+---------------------+
| -8999999999999999.9 |
+---------------------+
1 row in set (0.055 sec)

Generated at Thu Feb 08 02:51:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.