questdb / py-questdb-client

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

Feature request: Annotation to auto generate the ILP types from a Python/Java class #33

Closed Ugbot closed 1 year ago

Ugbot commented 1 year ago

ILP types are easy to get wrong and with python not always being obvious about this, it can happen every easily and with serious consequences for accuracy (doubles into floats etc).

Java is better about types but its still easy to make mistakes

My request is adding at annotation that can read a class's members generate the a method to create the ILP of the object that respects the types.

amunra commented 1 year ago

Could you provide an example of situations when it's tricky? The Python / ILP type mappings are these: https://py-questdb-client.readthedocs.io/en/latest/api.html#questdb.ingress.Buffer.row

Note that ILP types don't quite match 1:1 with QuestDB types. For example the FLOAT ILP type always gets encoded as a 64-bit float and never a 32-bit float over the wire.

In short, if you need specific types then you need to issue a CREATE TABLE statement ahead of time and the ILP types will be cast to the QuestDB column types according to the casting rules as detailed in this page: https://questdb.io/docs/reference/api/ilp/columnset-types/.

Before embarking on new features, I'd really like to understand your pain points / hopes & expectations in more detail.

amunra commented 1 year ago

Closing due to inactivity. If you have follow-up information, please re-open and comment.