questdb / py-questdb-client

Python client for QuestDB InfluxDB Line Protocol
https://py-questdb-client.readthedocs.io
Apache License 2.0
50 stars 8 forks source link

Sender.row() should allow insertion of NULL values using python None value #3

Closed salsasepp closed 2 years ago

salsasepp commented 2 years ago

Describe the bug

When specifying None for a column value in Sender.row(), I see this error message:

Traceback (most recent call last):
File "reproduce.py", line 7, in <module>
    sender.row('test',
  File "src/questdb/ingress.pyx", line 1237, in questdb.ingress.Sender.row
  File "src/questdb/ingress.pyx", line 719, in questdb.ingress.Buffer.row
  File "src/questdb/ingress.pyx", line 654, in questdb.ingress.Buffer._row
  File "src/questdb/ingress.pyx", line 649, in questdb.ingress.Buffer._row
  File "src/questdb/ingress.pyx", line 583, in questdb.ingress.Buffer._column
TypeError: Unsupported type: <class 'NoneType'>. Must be one of: bool, int, float, str, TimestampMicros, datetime.datetime

To reproduce

Web console:

CREATE TABLE test(data STRING)

reproduce.py:

from questdb.ingress import Sender

with Sender('localhost', 9009) as sender:
    # This works as expected:
    sender.row('test',
        columns={'data': 'somedata'}
    )
    # This fails:
    sender.row('test',
        columns={'data': None}
    )
    sender.flush()

Expected behaviour:

I would expect a NULL value to be inserted into the table when I specify None.

I am aware that I can work around this issue by leaving out the column I want to NULL from the columns parameter. However it would be nice if the client library would take care of that. Also, such a workaround fails if the column to be nulled is the only one or if I want to null all columns ("questdb.ingress.IngressError: Must specify at least one symbol or column").

Environment

Linux desktop 5.15.0-41-generic #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux questdb-6.4.3-rt-linux-amd64 Python 3.10.4

marregui commented 2 years ago

Hi @salsasepp thank you for the report, sure, will get done.