MonetDBSolutions / MonetDBe-Python

Embedded MonetDB with a Python frontend and fast Numpy/Pandas support
Mozilla Public License 2.0
61 stars 7 forks source link

Missing Key 5 in monet_c_type_map #174

Open mizadri opened 2 years ago

mizadri commented 2 years ago

Describe the bug

The variable monet_c_type_map does not contain the type 5 (which should be the Decimal). The return variable by the C code is allocating a bigger size for the result of aggregation operations on Decimal columns. And python does not know how to deal with this bigger decimal variables. The specific error was trying to access to a missing key in the monet C type dictionary (KeyError: 5):

 File "/usr/local/lib/python3.10/dist-packages/monetdbe/connection.py", line 137, in <genexpr>
    type_code = (monet_c_type_map[rcol.type].sql_type for rcol in columns)

To Reproduce Running any queries with aggregation operations or divisions on Decimal columns. Even divisions on Decimals will trigger this bug. For instance, this query:

select sum(P_RETAILPRICE) from part;

The issue was avoided after casting the result of sum/avg to Double. I had to change the following TPCH queries (3, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 17, 18, 19, 22).

The previous example would properly run when adding the cast:

select cast(sum(P_RETAILPRICE) as Double) from part;

Expected behavior The expected behavior was that all TPCH queries run with he same syntax as in MonetDB.

Software versions

njnes commented 7 months ago

You probably created your monetdbe with 128 bit integers support. Please try to compile with -DINT128=OFF