Open
Description
Describe the bug
A StreamFailureError
is raised when executing a query that contains a column with JSON
datatype, containing a Tuple(Int8, String)
.
Steps to reproduce
Example query:
SELECT '{"k": [123, "xyz"]}'::JSON SETTINGS input_format_json_read_numbers_as_strings = 0;
Apply this patch with unit test case and run the test:
diff --git a/tests/integration_tests/test_dynamic.py b/tests/integration_tests/test_dynamic.py
index bb8df62..f2a1821 100644
--- a/tests/integration_tests/test_dynamic.py
+++ b/tests/integration_tests/test_dynamic.py
@@ -162,3 +162,14 @@ def test_json_str_time(test_client: Client):
pytest.skip('JSON string/numbers bug before 25.1, skipping')
result = test_client.query("SELECT '{\"timerange\": \"2025-01-01T00:00:00+0000\"}'::JSON").result_set
assert result[0][0]['timerange'] == datetime.datetime(2025, 1, 1)
+
+def test_json_mixed_array(test_client: Client):
+ type_available(test_client, 'json')
+ if not test_client.min_version('24.10'):
+ pytest.skip('Complex JSON broken before 24.10')
+
+ # Raises:
+ # clickhouse_connect.driver.exceptions.StreamFailureError: unrecognized data found in stream: `000000000000000101135475706c6528496e74382c20537472696e67290000000000000000017b0378797a0000000000000000`
+ result = test_client.query('SELECT \'{"k": [123, "xyz"]}\'::JSON SETTINGS input_format_json_read_numbers_as_strings = 0')
+ json1 = result.result_set[0][0]
+ assert json1 == {'k': [123, 'xyz']}
raise StreamFailureError(extract_error_message(source.last_message)) from None
E clickhouse_connect.driver.exceptions.StreamFailureError: unrecognized data found in stream: `000000000000000101135475706c6528496e74382c20537472696e67290000000000000000017b0378797a0000000000000000`
Expected behaviour
The above test should pass and no StreamFailureError
should be raised.
Code example
See patch above.
clickhouse-connect and/or ClickHouse server logs
Configuration
Environment
- clickhouse-connect version: master (8d88b1c)
- Python version: 3.10
- Operating system: mac OS
ClickHouse server
- ClickHouse Server version: 24.12