Skip to content

Commit

Permalink
Update client revision to 54460
Browse files Browse the repository at this point in the history
  • Loading branch information
xzkostyan committed Dec 13, 2023
1 parent f088802 commit 3452ffc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clickhouse_driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .dbapi import connect


VERSION = (0, 2, 6)
VERSION = (0, 2, 7)
__version__ = '.'.join(str(x) for x in VERSION)

__all__ = ['Client', 'connect']
3 changes: 2 additions & 1 deletion clickhouse_driver/defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM = 54458
DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY = 54458
DBMS_MIN_PROTOCOL_VERSION_WITH_PARAMETERS = 54459
DBMS_MIN_PROTOCOL_VERSION_WITH_SERVER_QUERY_TIME_IN_PROGRESS = 54460

# Timeouts
DBMS_DEFAULT_CONNECT_TIMEOUT_SEC = 10
Expand All @@ -45,7 +46,7 @@
CLIENT_VERSION_MAJOR = 20
CLIENT_VERSION_MINOR = 10
CLIENT_VERSION_PATCH = 2
CLIENT_REVISION = DBMS_MIN_PROTOCOL_VERSION_WITH_PARAMETERS
CLIENT_REVISION = DBMS_MIN_PROTOCOL_VERSION_WITH_SERVER_QUERY_TIME_IN_PROGRESS

BUFFER_SIZE = 1048576

Expand Down
6 changes: 6 additions & 0 deletions clickhouse_driver/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def __init__(self):
self.total_rows = 0
self.written_rows = 0
self.written_bytes = 0
self.elapsed_ns = 0

super(Progress, self).__init__()

Expand All @@ -24,9 +25,14 @@ def read(self, server_info, fin):
self.written_rows = read_varint(fin)
self.written_bytes = read_varint(fin)

if revision >= defines. \
DBMS_MIN_PROTOCOL_VERSION_WITH_SERVER_QUERY_TIME_IN_PROGRESS:
self.elapsed_ns = read_varint(fin)

def increment(self, another_progress):
self.rows += another_progress.rows
self.bytes += another_progress.bytes
self.total_rows += another_progress.total_rows
self.written_rows += another_progress.written_rows
self.written_bytes += another_progress.written_bytes
self.elapsed_ns += another_progress.elapsed_ns
5 changes: 4 additions & 1 deletion docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ Statistics is sent from ClickHouse server and calculated on client side.
- total rows;
- written rows (*new in version 0.1.3*);
- written bytes (*new in version 0.1.3*);
- elapsed nanoseconds on server side (*new in version 0.2.7*);

.. code-block:: python
Expand All @@ -197,8 +198,10 @@ Statistics is sent from ClickHouse server and calculated on client side.
80
>>> client.last_query.progress.total_rows
10
>>> client.last_query.progress.elapsed_ns
5328901
* elapsed time:
* elapsed time calculated on client (driver) side:

.. code-block:: python
Expand Down
12 changes: 12 additions & 0 deletions tests/test_query_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def test_store_last_query_after_execute(self):
self.assertEqual(last_query.progress.rows, 42)
self.assertEqual(last_query.progress.bytes, 42)
self.assertEqual(last_query.progress.total_rows, 0)
if self.server_version > (22, 8):
self.assertGreater(last_query.progress.elapsed_ns, 0)

self.assertGreater(last_query.elapsed, 0)

Expand All @@ -50,6 +52,8 @@ def test_last_query_after_execute_iter(self):
self.assertEqual(last_query.progress.rows, 42)
self.assertEqual(last_query.progress.bytes, 42)
self.assertEqual(last_query.progress.total_rows, 0)
if self.server_version > (22, 8):
self.assertGreater(last_query.progress.elapsed_ns, 0)

self.assertEqual(last_query.elapsed, 0)

Expand All @@ -68,6 +72,8 @@ def test_last_query_after_execute_with_progress(self):
self.assertEqual(last_query.progress.rows, 42)
self.assertEqual(last_query.progress.bytes, 42)
self.assertEqual(last_query.progress.total_rows, 0)
if self.server_version > (22, 8):
self.assertGreater(last_query.progress.elapsed_ns, 0)

self.assertEqual(last_query.elapsed, 0)

Expand All @@ -85,6 +91,8 @@ def test_last_query_progress_total_rows(self):

total_rows = 10 if self.server_version > (19, 4) else 0
self.assertEqual(last_query.progress.total_rows, total_rows)
if self.server_version > (22, 8):
self.assertGreater(last_query.progress.elapsed_ns, 0)

self.assertGreater(last_query.elapsed, 0)

Expand All @@ -98,6 +106,8 @@ def test_last_query_after_execute_insert(self):
self.assertIsNotNone(last_query.progress)
self.assertEqual(last_query.progress.rows, 0)
self.assertEqual(last_query.progress.bytes, 0)
if self.server_version > (22, 8):
self.assertEqual(last_query.progress.elapsed_ns, 0)

self.assertGreater(last_query.elapsed, 0)

Expand Down Expand Up @@ -148,5 +158,7 @@ def test_progress_info_ddl(self):
self.assertIsNotNone(last_query.progress)
self.assertEqual(last_query.progress.rows, 0)
self.assertEqual(last_query.progress.bytes, 0)
if self.server_version > (22, 8):
self.assertEqual(last_query.progress.elapsed_ns, 0)

self.assertGreater(last_query.elapsed, 0)

0 comments on commit 3452ffc

Please sign in to comment.