Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported data type: JSON #1023

Closed
aarcha123 opened this issue Jul 29, 2022 · 6 comments
Closed

Unsupported data type: JSON #1023

aarcha123 opened this issue Jul 29, 2022 · 6 comments
Assignees

Comments

@aarcha123
Copy link

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)
@zhicwu
Copy link
Contributor

zhicwu commented Jul 29, 2022

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.

@aarcha123
Copy link
Author

Thank you @zhicwu

@Martin7-1
Copy link

Martin7-1 commented Oct 12, 2024

@zhicwu Hi, I encounter this exception when I want to select JSON data type. My code:

String sql = "SELECT id,text,embedding,metadata, dist " + 
"FROM table ORDER BY cosineDistance(embedding, [0.1, 0.2, 0.3]) AS dist ASC LIMIT 1000";

Records records = client.queryRecords(sql).get(3000, TimeUnit.MILLISECONDS)

And clickhouse-client throw Exception Caused by: java.lang.IllegalArgumentException: Unsupported data type: JSON.

I have setting allow_experimental_json_type = 1 and allow_experimental_vector_similarity_index = 1 when I create table. Any idea?

Dependency:

client-v2: 0.7.0
clickhouse-version: 24.9.2.42

@mzitnik
Copy link
Contributor

mzitnik commented Oct 28, 2024

@Martin7-1 can you open a dedicated issue for it.
@chernser can you take a look

@Martin7-1
Copy link

@mzitnik Hi! Thank you for your reply, I think this problem is related to #1833.

@mzitnik
Copy link
Contributor

mzitnik commented Oct 28, 2024

Duplicate of #1833

@mzitnik mzitnik marked this as a duplicate of #1833 Oct 28, 2024
@mzitnik mzitnik closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants