[MCOL-4660] Narow decimal to string conversion is inconsistent about zero integral Created: 2021-04-03  Updated: 2021-04-09  Resolved: 2021-04-09

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 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-4615 GROUP_CONCAT() precision loss for hug... Closed

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(10,3)) ENGINE=ColumnStore;
INSERT INTO t1 VALUES (0),(0.009),(0.09),(0.9);
SELECT CONCAT(a), CAST(a AS CHAR) FROM t1;

+-----------+-----------------+
| CONCAT(a) | CAST(a AS CHAR) |
+-----------+-----------------+
| 0.000     | 0.000           |
| .009      | .009            |
| .090      | .090            |
| 0.900     | 0.900           |
+-----------+-----------------+

Notice inconsistency:

  • it prints the 0 in the integral part if the first fractional digit is not 0.
  • it does not print the 0 in the integral part if the first fractional digit is zero.

Note, the problem is not repeatable with wide decimal:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(30,3)) ENGINE=ColumnStore;
INSERT INTO t1 VALUES (0),(0.009),(0.09),(0.9);
SELECT CONCAT(a), CAST(a AS CHAR) FROM t1;

+-----------+-----------------+
| CONCAT(a) | CAST(a AS CHAR) |
+-----------+-----------------+
| 0.000     | 0.000           |
| 0.009     | 0.009           |
| 0.090     | 0.090           |
| 0.900     | 0.900           |
+-----------+-----------------+



 Comments   
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

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