Full DECIMAL support in ColumnStore (MCOL-641)

[MCOL-4174] Review/refactor frontend/connector code. Created: 2020-07-13  Updated: 2020-11-20  Resolved: 2020-11-20

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: None
Fix Version/s: 5.4.1

Type: Sub-Task Priority: Major
Reporter: Roman Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Sprint: 2020-1, 2020-2, 2020-3, 2020-4, 2020-5, 2020-6, 2020-7, 2021-1, 2021-2, 2021-3, 2021-4, 2021-5, 2021-6, 2021-7, 2021-8, 2021-9

 Comments   
Comment by Gagan Goel (Inactive) [ 2020-11-19 ]

Looks like we broke the connector UDF code with this patch (i.e. the changes to dbcon/mysql/ha_mcs_partition.cpp):

MariaDB [test]> create table cs1 (a int)engine=columnstore;
Query OK, 0 rows affected (0.650 sec)
 
MariaDB [test]> select calshowpartitions('cs1', 'a');
+--------------------------------------------------------------------------------------------------+
| calshowpartitions('cs1', 'a')                                                                    |
+--------------------------------------------------------------------------------------------------+
| Part#     Min                           Max                           Status
  0.0.1     Enabled |
+--------------------------------------------------------------------------------------------------+
1 row in set (0.048 sec)
 
MariaDB [test]> insert into cs1 values (123), (234);
Query OK, 2 rows affected (0.407 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
MariaDB [test]> select calshowpartitions('cs1', 'a');
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| calshowpartitions('cs1', 'a')                                                                                                                                |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Part#     Min                           Max                           Status
  0.0.1     N/A                           N/A                           Enabled |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)
 
MariaDB [test]> select * from cs1;
+------+
| a    |
+------+
|  123 |
|  234 |
+------+
2 rows in set (0.097 sec)
 
MariaDB [test]> select calshowpartitions('cs1', 'a');
+--------------------------------------------------------------------------------------------------+
| calshowpartitions('cs1', 'a')                                                                    |
+--------------------------------------------------------------------------------------------------+
| Part#     Min                           Max                           Status
  0.0.1     Enabled |
+--------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

The expected output is the following:

MariaDB [test]> create table cs1 (a int)engine=columnstore;
Query OK, 0 rows affected (0.472 sec)
 
MariaDB [test]> select calshowpartitions('cs1', 'a');
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| calshowpartitions('cs1', 'a')                                                                                                                                |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Part#     Min                           Max                           Status
  0.0.1     Empty/Null                    Empty/Null                    Enabled |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.048 sec)
 
MariaDB [test]> insert into cs1 values (123), (234);
Query OK, 2 rows affected (0.357 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
MariaDB [test]> select calshowpartitions('cs1', 'a');
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| calshowpartitions('cs1', 'a')                                                                                                                                |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Part#     Min                           Max                           Status
  0.0.1     N/A                           N/A                           Enabled |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)
 
MariaDB [test]> select * from cs1;
+------+
| a    |
+------+
|  123 |
|  234 |
+------+
2 rows in set (0.080 sec)
 
MariaDB [test]> select calshowpartitions('cs1', 'a');
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| calshowpartitions('cs1', 'a')                                                                                                                                |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Part#     Min                           Max                           Status
  0.0.1     123                           234                           Enabled |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

Other UDFs might also have issues, I only tried calshowpartitions().

Comment by Alexander Barkov [ 2020-11-20 ]

The bug seems to be in this piece of the code in ha_mcs_partition.cpp:

        for (partIt = partMap.begin(); partIt != partMap.end(); ++partIt)
        {
            ostringstream oss;
            oss << partIt->first;        for (partIt = partMap.begin(); partIt != partMap.end(); ++partIt)
        {
            ostringstream oss;
            oss << partIt->first;
            output << "\n  " << setw(10) << oss.str();
 
            if (partIt->second.is_invalid())
            {
                output << setw(valueCharLength) << "N/A"
                       << setw(valueCharLength) << "N/A";
            }
            else
            {
                const datatypes::TypeHandler *h= ct.typeHandler();
                oss << h->formatPartitionInfo(ct, partIt->second);

The last line should be:

                output << h->formatPartitionInfo(ct, partIt->second);

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