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

Select JSON column Exception by using query() function #265

Closed
Libao-Yang opened this issue Nov 7, 2023 · 2 comments · Fixed by #266
Closed

Select JSON column Exception by using query() function #265

Libao-Yang opened this issue Nov 7, 2023 · 2 comments · Fixed by #266
Assignees
Labels
bug Something isn't working

Comments

@Libao-Yang
Copy link

Describe the bug

When a select operation is performed using the query() function, an exception is thrown if the result contains complex JSON format.

Steps to reproduce

  1. create a JSON table
CREATE TABLE IF NOT EXISTS test_table (id Int32, json JSON) ENGINE = MergeTree() ORDER BY id;
  1. insert the complex data
:) select * from test_table Format JSONEachRow;

{"id":2,"json":{"content":"This is a description of the book","metadata":{"Author":"test","Number of pages":"","Title":"title","Year of Original Publication":"","Year of Publication":"2023"}}}
  1. use query() function failed
res = client.query("SELECT * FROM test_table")
clickhouse_connect.driver.exceptions.InternalError: Unrecognized ClickHouse type base: ofpages`String name: ofpages`String
@Libao-Yang Libao-Yang added the bug Something isn't working label Nov 7, 2023
@genzgd
Copy link
Collaborator

genzgd commented Nov 7, 2023

This bug is related to having spaces in your keys ('like a key of Number of pages). ClickHouse parses that as a tuple element. I'll see if I can improve the parser to handle that correctly, but the quickest workaround is to not use keys with spaces.

@genzgd genzgd linked a pull request Nov 7, 2023 that will close this issue
2 tasks
@genzgd
Copy link
Collaborator

genzgd commented Nov 8, 2023

This should be fixed in 0.6.19, although any time you have to deal with spaces in a column name there's always a chance of weird bugs.

@genzgd genzgd self-assigned this Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants