[MCOL-1816] mcsapi - support bool data type Created: 2018-10-17  Updated: 2023-10-26  Resolved: 2018-11-09

Status: Closed
Project: MariaDB ColumnStore
Component/s: None
Affects Version/s: 1.2.0
Fix Version/s: 1.2.1

Type: New Feature Priority: Major
Reporter: Jens Röwekamp (Inactive) Assignee: Zdravelina Sokolovska (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File MCOL_1816.cpp     Java Source File MCOL_1816.java     Text File MCOL_1816.py     File MCOL_1816.sql    
Issue Links:
Blocks
blocks MCOL-1817 Pentaho support bool data type Closed
blocks MCOL-1818 Informatica support bool data type Closed
Sprint: 2018-20

 Description   

With the new introduction of the boolean data type, mcsapi should support it as well.



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2018-10-18 ]

jens.rowekamp Since BOOL is an alias for TINYINT(1) (and the data type will be set to TINYINT when you try BOOL) how does it not already support it?

Comment by Jens Röwekamp (Inactive) [ 2018-10-18 ]

ah okay didn't know that it is just an alias.

C++ and Python seem to typecast boolean data types automatically to 0 and 1, but Java unfortunately doesn't.

[jens@centos7 ~]$ javac -classpath ".:/usr/lib64/javamcsapi.jar" MCOL_1816.java
MCOL_1816.java:10: error: no suitable method found for setColumn(int,boolean)
        b.setColumn(0, false);
         ^
    method ColumnStoreBulkInsert.setColumn(int,String) is not applicable
      (argument mismatch; boolean cannot be converted to String)
    method ColumnStoreBulkInsert.setColumn(int,BigInteger) is not applicable
      (argument mismatch; boolean cannot be converted to BigInteger)
    method ColumnStoreBulkInsert.setColumn(int,long) is not applicable
      (argument mismatch; boolean cannot be converted to long)
    method ColumnStoreBulkInsert.setColumn(int,int) is not applicable
      (argument mismatch; boolean cannot be converted to int)
    method ColumnStoreBulkInsert.setColumn(int,short) is not applicable
      (argument mismatch; boolean cannot be converted to short)
    method ColumnStoreBulkInsert.setColumn(int,byte) is not applicable
      (argument mismatch; boolean cannot be converted to byte)
    method ColumnStoreBulkInsert.setColumn(int,double) is not applicable
      (argument mismatch; boolean cannot be converted to double)
    method ColumnStoreBulkInsert.setColumn(int,ColumnStoreDateTime) is not applicable
      (argument mismatch; boolean cannot be converted to ColumnStoreDateTime)
    method ColumnStoreBulkInsert.setColumn(int,ColumnStoreTime) is not applicable
      (argument mismatch; boolean cannot be converted to ColumnStoreTime)
    method ColumnStoreBulkInsert.setColumn(int,ColumnStoreDecimal) is not applicable
      (argument mismatch; boolean cannot be converted to ColumnStoreDecimal)
MCOL_1816.java:12: error: no suitable method found for setColumn(int,boolean)
        b.setColumn(0, true);
         ^
    method ColumnStoreBulkInsert.setColumn(int,String) is not applicable
      (argument mismatch; boolean cannot be converted to String)
    method ColumnStoreBulkInsert.setColumn(int,BigInteger) is not applicable
      (argument mismatch; boolean cannot be converted to BigInteger)
    method ColumnStoreBulkInsert.setColumn(int,long) is not applicable
      (argument mismatch; boolean cannot be converted to long)
    method ColumnStoreBulkInsert.setColumn(int,int) is not applicable
      (argument mismatch; boolean cannot be converted to int)
    method ColumnStoreBulkInsert.setColumn(int,short) is not applicable
      (argument mismatch; boolean cannot be converted to short)
    method ColumnStoreBulkInsert.setColumn(int,byte) is not applicable
      (argument mismatch; boolean cannot be converted to byte)
    method ColumnStoreBulkInsert.setColumn(int,double) is not applicable
      (argument mismatch; boolean cannot be converted to double)
    method ColumnStoreBulkInsert.setColumn(int,ColumnStoreDateTime) is not applicable
      (argument mismatch; boolean cannot be converted to ColumnStoreDateTime)
    method ColumnStoreBulkInsert.setColumn(int,ColumnStoreTime) is not applicable
      (argument mismatch; boolean cannot be converted to ColumnStoreTime)
    method ColumnStoreBulkInsert.setColumn(int,ColumnStoreDecimal) is not applicable
      (argument mismatch; boolean cannot be converted to ColumnStoreDecimal)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors

We could either add a boolean datatype to the C++ layer to enable Java to support boolean data types as well or I can solve it within Swig.
I argue that it is better to fix it in the C++ layer, as we don't know if future language bindings would have the same issue and we would have to fix it in Swig for them as well.

Comment by Andrew Hutchings (Inactive) [ 2018-11-05 ]

Added to the C++ API. Assigned to Jens to review and add compatibility for other APIs

Comment by Zdravelina Sokolovska (Inactive) [ 2018-11-09 ]

[root@cps mcsimport]# python
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymcsapi
>>>
>>> d = pymcsapi.ColumnStoreDriver()
>>> b = d.createBulkInsert("test", "MCOL_01816", 0, 0)
>>> b.setColumn(0, False)
[<pymcsapi.ColumnStoreBulkInsert; proxy of <Swig Object of type 'mcsapi::ColumnStoreBulkInsert *' at 0x7fc118a81ae0> >, 0]
>>> b.writeRow()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/pymcsapi.py", line 600, in writeRow
return _pymcsapi.ColumnStoreBulkInsert_writeRow(self)
RuntimeError: Not all the columns for this row have been filled
>>> b.setColumn(1, True)
[<pymcsapi.ColumnStoreBulkInsert; proxy of <Swig Object of type 'mcsapi::ColumnStoreBulkInsert *' at 0x7fc118a88960> >, 0]
>>> b.writeRow()
<pymcsapi.ColumnStoreBulkInsert; proxy of <Swig Object of type 'mcsapi::ColumnStoreBulkInsert *' at 0x7fc118a81ae0> >
>>> b.commit()
>>>
>>>
>>>
>>>
>>>
>>> import pymcsapi
>>>
>>> d = pymcsapi.ColumnStoreDriver()
>>> b = d.createBulkInsert("test", "MCOL_01816", 0, 0)
>>> b.setColumn(0, False)
[<pymcsapi.ColumnStoreBulkInsert; proxy of <Swig Object of type 'mcsapi::ColumnStoreBulkInsert *' at 0x7fc118a81b10> >, 0]
>>>
>>> b.setColumn(1, True)
[<pymcsapi.ColumnStoreBulkInsert; proxy of <Swig Object of type 'mcsapi::ColumnStoreBulkInsert *' at 0x7fc118a81ae0> >, 0]
>>> b.writeRow()
<pymcsapi.ColumnStoreBulkInsert; proxy of <Swig Object of type 'mcsapi::ColumnStoreBulkInsert *' at 0x7fc118a81b10> >
>>> b.commit()
>>>
>>>
>>>
KeyboardInterrupt
>>>
[4]+ Stopped python
[root@cps mcsimport]# mcsmysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 38
Server version: 10.3.10-MariaDB-log Columnstore 1.2.1-1

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select * from test.MCOL_01816 ;
----------+

a b

----------+

0 1
0 1

----------+
2 rows in set, 1 warning (0.045 sec)

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