Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose columnar to execute_with_progress #108

Merged
merged 2 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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