[MCOL-4607] SEC_TO_TIME(wideDecimal) returns 0 in DECIMAL context Created: 2021-03-15  Updated: 2023-07-02

Status: Open
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 5.6.1, 6.1.1
Fix Version/s: Icebox

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

Issue Links:
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-4651 SEC_TO_TIME(hugePositiveDecimal) retu... Closed

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(30,1)) ENGINE=ColumnStore;
INSERT INTO t1 VALUES (1);
SELECT SEC_TO_TIME(a), SEC_TO_TIME(a)+0.0 FROM t1;

+----------------+--------------------+
| SEC_TO_TIME(a) | SEC_TO_TIME(a)+0.0 |
+----------------+--------------------+
| 00:00:01.0     |                0.0 |
+----------------+--------------------+

Notice, SEC_TO_TIME(a) per se returned a correct result, but when I further put it into a DECIMAL plus operation, it returned 0.

The expected result is:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(30,1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
SELECT SEC_TO_TIME(a), SEC_TO_TIME(a)+0.0 FROM t1;

+----------------+--------------------+
| SEC_TO_TIME(a) | SEC_TO_TIME(a)+0.0 |
+----------------+--------------------+
| 00:00:01.0     |                1.0 |
+----------------+--------------------+



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

The problem happens because Func_sec_to_time::getDecimalVal() does not set the `precision` member for the output value.

Comment by Mu He [ 2023-03-24 ]

The reason should be here, the issue could be solved by just assigning d.value = tmpVal for all situation or like d.value = d.s128Value = tmpVal inside the if statement.

It may mean that the data is recognized as a wide decimal but read the value instead rather than the s128Value.

Comment by Mu He [ 2023-03-24 ]

I think we should use op_ct.isWideDecimalType() here instead of parm[0]>data()>resultType().isWideDecimalType(). After replacing it could work.

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