Skip to content

Commit

Permalink
Calculate elapsed time on INSERTs
Browse files Browse the repository at this point in the history
  • Loading branch information
xzkostyan committed Jul 29, 2019
1 parent 1795e39 commit 6b6148a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
### Added
- SimpleAggregateFunction type.

### Fixed
- Elapsed time calculation on INSERT.

## [0.0.20] - 2019-06-02
### Added
- LowCardinality(T) type.
Expand Down
2 changes: 1 addition & 1 deletion clickhouse_driver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def execute(self, query, params=None, with_column_types=False,
query_id=query_id, types_check=types_check,
columnar=columnar
)
self.last_query.store_elapsed(time() - start_time)
self.last_query.store_elapsed(time() - start_time)
return rv

except Exception:
Expand Down
12 changes: 10 additions & 2 deletions tests/test_query_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_store_last_query_after_execute(self):
assert last_query.progress.bytes == 42
assert last_query.progress.total_rows == 0

assert last_query.elapsed is not None
assert last_query.elapsed >= 0

def test_last_query_after_execute_iter(self):
Expand Down Expand Up @@ -88,7 +87,16 @@ def test_last_query_progress_total_rows(self):
total_rows = 10 if current > (19, 4) else 0
assert last_query.progress.total_rows == total_rows

assert last_query.elapsed is not None
assert last_query.elapsed >= 0

def test_last_query_after_execute_insert(self):
with self.sample_table():
self.client.execute('INSERT INTO test (foo) VALUES',
[(i,) for i in range(42)])

last_query = self.client.last_query
assert last_query is not None
assert last_query.progress is None
assert last_query.elapsed >= 0

def test_override_after_subsequent_queries(self):
Expand Down

0 comments on commit 6b6148a

Please sign in to comment.