-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of ISO8601 timestamp strings for inserting into table with DateTime64 column type #439
Comments
Regarding the "bug", microseconds are added to the (int) of the float value. This is to avoid rounding errors that are inherent in the underlying float value. As for the enhancement request, it makes sense but such an enhancement would be doing exactly the same thing as you do yourself, and there are many other string formats that are not supported natively by Python. There's no harm in it but it would have the same performance hit. |
Thank you for your answer, Oh, now I see (about rounding errors avoiding). Regarding the topic of datetime formats, I think that support of a datetime standard (ISO8601) which is can be done with standard tools of language generally has a place in the library. I understand your point that the same conversion operation can be performed at the main level code, not at the library level. However, I rather pursued the goal of minimizing the conversion logic in the main code and delegating it to the library (not for all date formats but only for international standard). For now I chose next solution that delegates parsing to ClickHouse server. ...
response = await self._client.raw_insert(
table=self._fq_table_name,
insert_block=('\n'.join(documents) + '\n'),
fmt='JSONEachRow'
)
... As the alternative I'm fully satisfied with that. So we can close that issue if implementation of suggestion is not intended. P.S. |
If you are starting with JSON initially, handing that off to the ClickHouse server using As I said, the enhancement makes sense but there are several other requests without a such clean workaround that will be higher priority. I'm happy to leave the issue open, but unless there is a community contribution it probably won't get worked on for quite some time. |
I added PR (#440) that touches only |
Current implementation gives us the opportunity to pass DateTime64 value as
int
ordatetime
object. I think it would be really helpful if it can be possible to pass DateTime64 value asstr
in ISO8601 format (e.g.2024-12-15T18:14:17.206854
).In my use case I receive some data from service in json format. Timestamps are stored as strings in ISO8601 format. For now I have to convert each document timestamp using
datetime.fromisoformat()
.I also notice some code fragment in DateTime64 class which is a potential bug. In
clickhouse_connect/datatypes/temporal.py
on line 211, microseconds are added to float value which is already includes microseconds.The text was updated successfully, but these errors were encountered: