[MCOL-4648] CAST(UBIGINTNULL_inWideDecimal AS UNSIGNED) returns 0 or NULL Created: 2021-03-30  Updated: 2023-09-22  Resolved: 2023-08-15

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

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Roman
Resolution: Fixed Votes: 0
Labels: beginner-friendly

Issue Links:
Blocks
is blocked by MCOL-3574 EMPTY column for persistant storage Closed
Relates
relates to MCOL-4361 Replace pow(10.0, (double)scale) expr... Closed
relates to MCOL-641 Full DECIMAL support in ColumnStore Closed
relates to MCOL-4632 CAST(hugeNegativeWideDecimal AS SIGNE... Closed
Sprint: 2023-8
Assigned for Review: Roman Roman
Assigned for Testing: Daniel Lee Daniel Lee (Inactive)

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d1 DECIMAL(30,0), d2 DECIMAL(30,0) NOT NULL) ENGINE=ColumnStore;
INSERT INTO t1 VALUES (18446744073709551614,18446744073709551614);
SELECT d1, CAST(d1 AS UNSIGNED), CAST(d2 AS UNSIGNED) FROM t1;

+----------------------+----------------------+----------------------+
| d1                   | CAST(d1 AS UNSIGNED) | CAST(d2 AS UNSIGNED) |
+----------------------+----------------------+----------------------+
| 18446744073709551614 |                 NULL |                    0 |
+----------------------+----------------------+----------------------+

The expected result is:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d1 DECIMAL(30,0), d2 DECIMAL(30,0) NOT NULL) ENGINE=InnoDB;
INSERT INTO t1 VALUES (18446744073709551614,18446744073709551614);
SELECT d1, CAST(d1 AS UNSIGNED), CAST(d2 AS UNSIGNED) FROM t1;

+----------------------+----------------------+----------------------+
| d1                   | CAST(d1 AS UNSIGNED) | CAST(d2 AS UNSIGNED) |
+----------------------+----------------------+----------------------+
| 18446744073709551614 | 18446744073709551614 | 18446744073709551614 |
+----------------------+----------------------+----------------------+

Note, in ColumnStore the value 18446744073709551614 is reserved for the magic value UBIGINTNULL. So perhaps in ColumnStore we'll have to return 18446744073709551613. But NULL and 0 are certainly wrong.



 Comments   
Comment by Daniel Lee (Inactive) [ 2023-04-25 ]

This issue still exist after the fix for MCOL-271.

Comment by Daniel Lee (Inactive) [ 2023-08-15 ]

Build verified: develop branch, latest
engine: c97c8b672e33e09e9cf66db39e6c013d398c97e3
server: 62d6100a913699fec9ff48284a76bfe6226e70bc
buildNo: 8420

MariaDB [mytest]> SELECT d1, CAST(d1 AS UNSIGNED), CAST(d2 AS UNSIGNED) FROM t1;
--------------------------------------------------------------

d1 CAST(d1 AS UNSIGNED) CAST(d2 AS UNSIGNED)

--------------------------------------------------------------

18446744073709551614 18446744073709551613 18446744073709551613

--------------------------------------------------------------
1 row in set (0.078 sec)

According to data types information in this page https://mariadb.com/docs/columnstore/sql/features/data-types/enterprise-columnstore/

The max unsigned value is 18446744073709551613.

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