clickhouse-java
clickhouse-java copied to clipboard
Unsupported data type: JSON
Using the below snippet results in "Unsupported data type: JSON:" using 0.3.2.patch11
PreparedStatement pstmt = connection.prepareStatement("INSERT INTO json_demo SELECT id,details from INPUT('id UInt8, details JSON')"); `
pstmt.setInt(1, 20);
pstmt.setObject(2, "{\"type\": \"Region\"}");
pstmt.addBatch();
pstmt.executeBatch();
Table definition
CREATE TABLE json_demo
( id UInt8,
details JSON)
ENGINE = MergeTree()
PRIMARY KEY (id)
Stack trace:
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported data type: JSON
at com.clickhouse.client.data.ClickHouseRowBinaryProcessor$MappedFunctions.serialize(ClickHouseRowBinaryProcessor.java:484)
at com.clickhouse.jdbc.internal.InputBasedPreparedStatement.addBatch(InputBasedPreparedStatement.java:333)
Hi @aarcha123, thanks for the report. It looks like now ClickHouse supports string format JSON object, which is way better than constructing a complex object in client. I'll update data type mapping accordingly in next release. Meanwhile, the workaround is simply change JSON to String in your insert query.
Thank you @zhicwu