Skip to content

Missing Key 5 in monet_c_type_map #174

Open
@mizadri

Description

@mizadri

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

  • Docker container (ubuntu:latest)
  • Python version: Python 3.10.4]
  • MonetDBe-Python version: 0.11

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions