MonetDBLite-Python icon indicating copy to clipboard operation
MonetDBLite-Python copied to clipboard

Results with repeating columns are not handled correctly

Open kutsurak opened this issue 6 years ago • 1 comments


import monetdblite as mdbl

c = mdbl.make_connection('/tmp/db')
cc = c.cursor()
cc.create('st', {'i': [1, 2, 3]})
cc.execute('select * from st,st')

The expected result is a table with two columns both named i.

The actual result is:

cc.fetchnumpy()

{'i': array([1, 1, 1, 2, 2, 2, 3, 3, 3])}

This seems to be an inherent limitation of how results are represented in MonetDBLite-Python, since we cannot have two different values in a dictionary with the same key. The workaround is to execute the query naming the columns explicitly:

cc.execute('select f1.i as i1, f2.i as i2 from st as f1, st as f2')
cc.fetchnumpy()

{'i1': array([1, 1, 1, 2, 2, 2, 3, 3, 3]),
 'i2': array([1, 2, 3, 1, 2, 3, 1, 2, 3])}

kutsurak avatar Mar 26 '19 17:03 kutsurak

The problem is at https://github.com/MonetDB/MonetDBLite-Python/blob/master/src/embeddedpy/embeddedpy.c#L121

kutsurak avatar Mar 27 '19 14:03 kutsurak