KxSystems / pyq

PyQ — Python for kdb+
http://code.kx.com/q/interfaces
Apache License 2.0
190 stars 49 forks source link

Null comparisons in kdb #84

Closed antipisa closed 6 years ago

antipisa commented 6 years ago
pyq.versions()
PyQ 4.1.3
NumPy 1.14.3
KDB+ 3.5 (2018.04.25) l64
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:17:00)
[GCC 7.2.0]

Generic null comparisons:

None from python should be converted to the kdb generic null which is ::

However, the comparison K(None)==q(‘::’) returns False.

>>> from pyq import q,K
>>> q('null a:(::)')
k('1b’)
>>> q.a
k('::')
>>> q.a.null
k('1b')
>>> q.b=K(None)
>>> q.b
k('::')
>>> q('a=b')
k('1b')
>>> q('null a')
k('1b')
>>> q('null b')
k('0b’)
>>> q.b.null
k(‘0b')
abalkin commented 6 years ago
>>> q.null(None)
k('0b')

(should be 1b)

will be fixed in the next release.

The reason for the strange behavior is that q's null only recognizes a singleton :: as null and

>>> K(None)._id() != q('::')._id()
True