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

Designated timestamp column name is always "timestamp" instead of the given name #68

Closed kasparthommen closed 6 months ago

kasparthommen commented 6 months ago
  1. I run the below code, where I want the column my_ts to be the designated timestamp:
df = pd.DataFrame({
    'my_ts': [pd.Timestamp(2024, 3, 21)],
    'my_col': [42],
})

conf = f'http::addr=localhost:9000;'
with Sender.from_conf(conf) as sender:
    sender.dataframe(df, table_name='foo', at='my_ts')
  1. The resulting table does not contain a my_ts column but timestamp instead. It should be called my_ts.

image

amunra commented 6 months ago

This is a limitation of the protocol that's used for ingestion: The timestamp is sent over the wire without name.

The work-around is pretty easy: Issue a CREATE TABLE sql statement in advance. This will allow you to be specific about other details like the specific datatypes of the columns you wish to use.

See: https://questdb.io/docs/reference/function/timestamp/

amunra commented 6 months ago

This is probably an area that needs better documentation here: https://py-questdb-client.readthedocs.io/en/latest/sender.html#table-and-column-auto-creation

kasparthommen commented 6 months ago

Fair point, thanks for the workaround/fix!