[MCOL-389] cast of int mod function to char results in trailing decimal points Created: 2016-11-06 Updated: 2017-01-16 Resolved: 2017-01-16 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | DMLProc |
| Affects Version/s: | 1.0.4 |
| Fix Version/s: | 1.0.7 |
| Type: | Bug | Priority: | Minor |
| Reporter: | David Thompson (Inactive) | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Sprint: | 2016-24, 2016-25, 2017-01 |
| Description |
|
The combination of mod and cast seems to result in addition of decimal points in the resulting string for columnstore table data. Note the 3rd query result, this should also be 1. create table t1(id int) engine=columnstore; MariaDB [loans]> select id from t1;
------
------ MariaDB [loans]> select cast(id as char) from t1;
------------------
------------------ MariaDB [loans]> select cast(mod(id,1024) as char) from t1;
----------------------------
---------------------------- MariaDB [loans]> select mod(id,1024) from t1;
--------------
-------------- |
| Comments |
| Comment by Andrew Hutchings (Inactive) [ 2016-12-19 ] | ||||||||
|
this is because cast calls getStrVal on the mod() which is part of the 'real' set of functions. With no override the parent class for func_mod calls getDouble() and then converts that. The fix is to implement getStrVal() for func_mod. | ||||||||
| Comment by Andrew Hutchings (Inactive) [ 2016-12-19 ] | ||||||||
|
Added support for int types for mod() instead of casting to double. For testing, from the original issue:
Should return 1.000000 before fix and 1 after fix. | ||||||||
| Comment by Daniel Lee (Inactive) [ 2017-01-16 ] | ||||||||
|
Build tested: [root@localhost mariadb-columnstore-server]# git show Merge pull request #26 from mariadb-corporation/ Update README.md MariaDB [mytest]> insert into t1 values (1); MariaDB [mytest]> select * from t1;
------
------ MariaDB [mytest]> select cast(id as char) from t1;
------------------
------------------ MariaDB [mytest]> select cast(mod(id,1024) as char) from t1
----------------------------
---------------------------- MariaDB [mytest]> select mod(id,1024) from t1;
--------------
-------------- MariaDB [mytest]> quit |