From 792df1a565587c8db223e72cccb53fa92515bd8c Mon Sep 17 00:00:00 2001 From: Carlos Yago Date: Tue, 16 Aug 2022 17:50:18 +0200 Subject: [PATCH] Fix handle 'Progress' packet while inserting (#326) --- clickhouse_driver/client.py | 3 +++ tests/test_insert.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/clickhouse_driver/client.py b/clickhouse_driver/client.py index 93a83990..21b548d0 100644 --- a/clickhouse_driver/client.py +++ b/clickhouse_driver/client.py @@ -589,6 +589,9 @@ def receive_end_of_query(self): if packet.type == ServerPacketTypes.END_OF_STREAM: break + elif packet.type == ServerPacketTypes.PROGRESS: + continue + elif packet.type == ServerPacketTypes.EXCEPTION: raise packet.exception diff --git a/tests/test_insert.py b/tests/test_insert.py index 7fbf512f..795fb71b 100644 --- a/tests/test_insert.py +++ b/tests/test_insert.py @@ -3,6 +3,7 @@ from tests.testcase import BaseTestCase from clickhouse_driver import errors from clickhouse_driver.errors import ServerException +from tests.util import require_server_version class InsertTestCase(BaseTestCase): @@ -148,6 +149,20 @@ def test_insert_return(self): ) self.assertEqual(rv, 5) + @require_server_version(22, 3, 6) + def test_insert_from_input(self): + with self.create_table('a Int8'): + data = [{'a': 1}] + self.client.execute( + "INSERT INTO test (a) " + "SELECT a from input ('a Int8')", + data + ) + + query = 'SELECT * FROM test' + inserted = self.emit_cli(query) + self.assertEqual(inserted, '1\n') + class InsertColumnarTestCase(BaseTestCase): def test_insert_tuple_ok(self):