Search code examples
pythonpandaskdbq-langexxeleron-q

Issue with null character received by qpython/pandas from kdb


This question is pretty much directed at @Maciej Lach but if anyone else has experienced this issue please let me know.

The issue is simple - qpyhton crashes (when pandas is set to true) whenever kdb sends it a single row table where one of the columns has a blank char.

I'm using: python version 2.7.11, qpython version qPython-1.2.0, pandas-0.18.1

To reproduce:

from qpython import qconnection

q = qconnection.QConnection(pandas = True, host = 'myhost', port = myport)

print 'initiating connection(s)'
q.open()

while True:
    msg = q.receive(data_only = True, raw = False)
    print 'message received'

Now, on the kdb side:

/send a table (which just so happens to have blank/null chars)
neg[4](`upd;`trade;([] col1:`a`b`c;col2:"  a"))
/no problem

/send last row of that table
neg[4](`upd;`trade;-1#([] col1:`a`b`c;col2:"  a"))
/no problem

/send two rows (2 blank chars)
neg[4](`upd;`trade;2#([] col1:`a`b`c;col2:"  a"))
/no problem

/send first row of that table (one blank char)
neg[4](`upd;`trade;1#([] col1:`a`b`c;col2:"  a"))
/crashes with error "AttributeError: 'float' object has no attribute 'meta'"

It seems to only have a problem when I send a single row table which has a null char. It's fine with more than one null char. It's fine with a single row table with non-null char. And everything is fine without the Pandas=True option (but I need pandas=True for my use case).

Any ideas?


Solution

  • This is a bug in the qPython library in version < 1.2.1.

    I've contributed a pull request with the fix to the maintainer.