Skip to content

Commit

Permalink
Clickhouse DateTime64 extended range (#222)
Browse files Browse the repository at this point in the history
Clickhouse DateTime64 extended range

ClickHouse/ClickHouse#9404
  • Loading branch information
0x4ec7 committed Jun 4, 2021
1 parent ddb4a6e commit 0e7f0b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clickhouse_driver/columns/datetimecolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def before_write_items(self, items, nulls_map=None):

class DateTime64Column(DateTimeColumn):
ch_type = 'DateTime64'
format = 'Q'
format = 'q'

max_scale = 6

Expand Down
15 changes: 15 additions & 0 deletions tests/columns/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ def test_insert_integer_bounds(self):
inserted = self.emit_cli(query)
self.assertEqual(inserted, '0\n1\n1500000000\n4294967295\n')

@require_server_version(21, 4)
def test_insert_datetime64_extended_range(self):
with self.create_table("a DateTime64(0, 'UTC')"):
self.client.execute(
'INSERT INTO test (a) VALUES',
[(0, ), (1, ), (-2**63, ), (2**63-1, )]
)

query = 'SELECT toInt64(a) FROM test ORDER BY a'
inserted = self.emit_cli(query)
self.assertEqual(
inserted,
'-9223372036854775808\n0\n1\n9223372036854775807\n'
)


class DateTimeTimezonesTestCase(BaseDateTimeTestCase):
dt_type = 'DateTime'
Expand Down

0 comments on commit 0e7f0b2

Please sign in to comment.