Skip to content

Commit

Permalink
Expose columnar to execute_with_progress (#108)
Browse files Browse the repository at this point in the history
* Expose columnar to  execute_with_progress

Right now there is no way to set columnar  in execute_with_progress. It seems all it was missing was to expose the parameter.

* Update test_blocks.py

Add test_select_with_columar_with_column_types
  • Loading branch information
igorbb authored and xzkostyan committed Sep 25, 2019
1 parent 8463794 commit dccd203
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 6 additions & 3 deletions clickhouse_driver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def execute(self, query, params=None, with_column_types=False,
def execute_with_progress(
self, query, params=None, with_column_types=False,
external_tables=None, query_id=None, settings=None,
types_check=False):
types_check=False, columnar=False):
"""
Executes SELECT query with progress information.
See, :ref:`execute-with-progress`.
Expand All @@ -244,6 +244,9 @@ def execute_with_progress(
Defaults to ``None`` (no additional settings).
:param types_check: enables type checking of data for INSERT queries.
Causes additional overhead. Defaults to ``False``.
:param columnar: if specified the result will be returned in
column-oriented form.
Defaults to ``False`` (row-like form).
:return: :ref:`progress-query-result` proxy.
"""

Expand All @@ -254,8 +257,8 @@ def execute_with_progress(
try:
return self.process_ordinary_query_with_progress(
query, params=params, with_column_types=with_column_types,
external_tables=external_tables,
query_id=query_id, types_check=types_check
external_tables=external_tables, query_id=query_id,
types_check=types_check, columnar=columnar
)

except Exception:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ def test_select_with_iter_error(self):

self.assertFalse(self.client.connection.connected)

def test_select_with_columar_with_column_types(self):
progress = self.client.execute_with_progress(
'SELECT arrayJoin(A) -1 as j,'
'arrayJoin(A)+1 as k FROM('
'SELECT range(3) as A)',
columnar=True, with_column_types=True)
rv = ([(-1, 0, 1), (1, 2, 3)], [('j', 'Int16'), ('k', 'UInt16')])
self.assertEqual(progress.get_result(), rv)
self.assertTrue(self.client.connection.connected)


class LogTestCase(BaseTestCase):
@require_server_version(18, 12, 13)
Expand Down

0 comments on commit dccd203

Please sign in to comment.