When I execute an INSERT INTO command using the httpclient, it returns an error if the insert query contains LIMIT 0.
Steps to reproduce
Create a table in Clickhouse or Clickhouse cloud
Use the httpclient to execute an INSERT INTO command whose query contains LIMIT 0
Expected behaviour
No error. (I realize that inserting the results of a query that returns no rows is pointless, but here we are.)
Code example
> self.execute("CREATE OR REPLACE TABLE test_insert (col1 Int8) order by ();")
> self.execute("INSERT INTO test_insert SELECT 1 LIMIT 0;")
Traceback (most recent call last):
File ".venv/lib/python3.11/site-packages/clickhouse_connect/dbapi/cursor.py", line 56, in execute
query_result = self.client.query(operation, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/clickhouse_connect/driver/client.py", line 209, in query
return self._query_with_context(query_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/clickhouse_connect/driver/httpclient.py", line 210, in _query_with_context
for col in json_result['meta']:
^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'json_result' where it is not associated with a value
Executing the same INSERT INTO query without LIMIT 0 works as expected and nothing is printed to terminal:
> self.execute("INSERT INTO test_insert SELECT 1;")
Describe the bug
When I execute an
INSERT INTO
command using the httpclient, it returns an error if the insert query containsLIMIT 0
.Steps to reproduce
INSERT INTO
command whose query containsLIMIT 0
Expected behaviour
No error. (I realize that inserting the results of a query that returns no rows is pointless, but here we are.)
Code example
Executing the same
INSERT INTO
query withoutLIMIT 0
works as expected and nothing is printed to terminal:Configuration
Environment
ClickHouse server