[MCOL-4465] UDAF with multiple arguments has a wrong ColType in a projection RowGroup Created: 2020-12-22  Updated: 2021-02-02  Resolved: 2021-01-29

Status: Closed
Project: MariaDB ColumnStore
Component/s: MDB Plugin
Affects Version/s: 6.1.1
Fix Version/s: 6.1.1

Type: Bug Priority: Minor
Reporter: Roman Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-641 Full DECIMAL support in ColumnStore Closed
Sprint: 2021-2

 Description   

The current plugin code sets the ColType in the projection RowGroup for UDAF using UDAF's first parameter. This might produce errors with a UDAF that has multiple arguments. Consider the example:

MariaDB [tpch1]> select * from (select CCHAR9, regr_count(CDECIMAL9_2, length(CCHAR9)) f from datatypetestm1 group by 1) a;
+-----------+------+
| CCHAR9    | f    |
+-----------+------+
| rrrrrrrr  |    0 |
| rrrrrrr   |    0 |
| iii       |    0 |
| i         |    0 |
| ii        |    0 |
| iiii      |    0 |
| zzzzzzzzz |    0 |
| aaaaaaaaa |    0 |
| rrrrrrrrr |    0 |
| NULL      |    0 |
+-----------+------+
10 rows in set (0.021 sec)
 
MariaDB [tpch1]> select * from (select CCHAR9, regr_count(CDECIMAL9_2, length(CCHAR9)) f from datatypetestm1 where CCHAR9 = 'ii' group by 1) a;
+--------+------+
| CCHAR9 | f    |
+--------+------+
| ii     |    0 |
+--------+------+
1 row in set (0.033 sec)

The f column contains 0 b/c f's ColType is a DECIMAL(9,2) so that Decimal TypeHandler first prints f value as '0.2' and stores it in the MDB's Field. MDB rounds the result to the nearest INT value that is 0 storing the string representation of the DECIMAL(9,2).

Here is what MCS must return.

MariaDB [test]> select * from (select CCHAR9, regr_count(CDECIMAL9_2, length(CCHAR9)) f from datatypetestm1 group by 1) a;
+-----------+------+
| CCHAR9    | f    |
+-----------+------+
| rrrrrrrr  |    2 |
| rrrrrrr   |    2 |
| iii       |    2 |
| i         |    2 |
| ii        |    2 |
| iiii      |    2 |
| zzzzzzzzz |    2 |
| aaaaaaaaa |    2 |
| rrrrrrrrr |    4 |
| NULL      |    0 |
+-----------+------+
10 rows in set (0.117 sec)
 
MariaDB [test]> select * from (select CCHAR9, regr_count(CDECIMAL9_2, length(CCHAR9)) f from datatypetestm1 where CCHAR9 = 'ii' group by 1) a;
+--------+------+
| CCHAR9 | f    |
+--------+------+
| ii     |    2 |
+--------+------+
1 row in set (0.037 sec)
 
MariaDB [test]> 



 Comments   
Comment by Daniel Lee (Inactive) [ 2021-01-29 ]

Build verified: 6.1.1 (Drone b1583)

Verified that results matching with InnoDB.

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