Closed
Description
Describe the bug
When using a PreparedStatement and setting a parameter as a UUID instance it causes the statement to fail.
Steps to reproduce
- Create a PreparedStatement using a UUID column
- Set the parameter to a direct UUID instance of Java
- See that ClickHouse fails on executing the statement
Expected behaviour
The statement should execute successfully.
Error log
Code: 47. DB::Exception: Missing columns: '83895f62363b' '8bb5' '4c20' 'b445' 'c4730b0d' while processing query:
'(((c4730b0d - b445) - `4c20`) - `8bb5`) - `83895f62363b`', required columns: 'c4730b0d' 'b445' '4c20' '8bb5' '83895f62363b'
'c4730b0d' 'b445' '4c20' '8bb5' '83895f62363b': While executing ValuesBlockInputFormat. (UNKNOWN_IDENTIFIER)
Additional info
The executed statement looks like this:
INSERT INTO "abc" ("id") VALUES (c4730b0d-b445-4c20-8bb5-83895f62363b)
As the quotes for the UUID are missing it seems to rather cause the separate parts of the UUID to be interpreted separately by ClickHouse.
I think the encodeObject
method in the PreparedStatementImpl
class should handle the UUID instances in a special way like Strings and surround them by quotes. This was also originally done in the deprecated ClickHouseValues
class.
Configuration
Environment
- Client version: 0.8.4
- Language version: Java 21
ClickHouse server
- ClickHouse Server version: 24.3