Skip to content

Commit

Permalink
[ClickHouse#439] Add support of ISO8601 timestamp strings for DateTim…
Browse files Browse the repository at this point in the history
…e64 column type
  • Loading branch information
rnv812 committed Dec 17, 2024
1 parent 29d61e9 commit d54d330
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clickhouse_connect/datatypes/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ def _write_column_binary(self, column: Union[Sequence, MutableSequence], dest: b
if isinstance(first, int) or self.write_format(ctx) == 'int':
if self.nullable:
column = [x if x else 0 for x in column]
elif isinstance(first, str) or self.write_format(ctx) == 'str':
original_column = column
column = []

for x in original_column:
if not x and self.nullable:
v = 0
else:
dt = datetime.fromisoformat(x)
v = ((int(dt.timestamp()) * 1000000 + dt.microsecond) * self.prec) // 1000000

column.append(v)
else:
prec = self.prec
if self.nullable:
Expand Down

0 comments on commit d54d330

Please sign in to comment.