question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"ClickHouse response without column types" when using CSV format

See original GitHub issue

Carlos N reported below issue on Telegram:

Carlos N, [28.01.21 05:44]
Hello, I am seeing the following exception when I use the CSV format for the response of my queries:

Caused by: java.lang.IllegalArgumentException: ClickHouse response without column types
 at ru.yandex.clickhouse.response.ClickHouseResultSet.<init>(ClickHouseResultSet.java:111)
 at ru.yandex.clickhouse.ClickHouseStatementImpl.createResultSet(ClickHouseStatementImpl.java:899)
 at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:122)

Carlos N, [28.01.21 05:44]
Has anybody found the issue before? It only happens with some of the most complex queries. I run.

Carlos N, [28.01.21 05:45]
I am using the default jdbc driver

Carlos N, [28.01.21 05:44]
Hello, I am seeing the following exception when I use the CSV format for the response of my queries:

Caused by: java.lang.IllegalArgumentException: ClickHouse response without column types
 at ru.yandex.clickhouse.response.ClickHouseResultSet.<init>(ClickHouseResultSet.java:111)
 at ru.yandex.clickhouse.ClickHouseStatementImpl.createResultSet(ClickHouseStatementImpl.java:899)
 at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:122)

Carlos N, [28.01.21 05:44]
Has anybody found the issue before? It only happens with some of the most complex queries. I run.

Carlos N, [28.01.21 05:45]
I am using the default jdbc driver

Carlos N, [28.01.21 08:58]
[In reply to Zhichun Wu]
Yes, we are using FORMAT because we wanted CSVWithNames, the issue doesn't occur without the FORMAT parameter. Is there a way for it to work with that parameter? This is the full query. 
select
    ...
from (
    ...
) as act
join ...
order by ...
 limit ? offset ? 
FORMAT CSVWithNames

Denny Crane [Junior support specialist at Altinity (NB,Canada)], [28.01.21 08:59]
The fact that following is working in JDBC

select 1 a, 'aaa' b
from numbers(2) 
FORMAT CSVWithNames

Is a bug and must be fixed. To avoid confusion.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
zhicwucommented, Jul 22, 2021

@zhicwu Hi! Is it possible to download csv file of “select … FORMAT CSV” via clickhouse-jdbc?

I think it’s doable using extended API. I’ll give it a shot tonight.

Update: it’s not as I only saw writer API 😕 I’ll commit a tailored version of the grpc client over the weekend. It should work as you can get InputStream from response and do whatever you want like writing results into a CSV file. For example:

ClickHouseNode server = ClickHouseNode.builder().withPort(ClickHouseProtocol.GRPC).build(); // localhost:9100
ClickHouseClient client = ClickHouseClient.builder().build(); // only gRPC is supported at this point
try (ClickHouseResponse response = client.connect(server).sql("select * from FORMAT CSV").execute().get()) {
    try (InputStream in = response.getInputStream()) {
        ...
    }
}
0reactions
zhicwucommented, Sep 9, 2021

Hi @zhicwu! Do you have any progress on this?

Thanks for your patience and sorry for no update for months. Fortunately, progress being made, stability and performance are improved, along with a few enhancements to the API, so now this can be simplified as following:

ClickHouseClient.dump(
  ClickHouseNode.builder()
    .withHost("my.ch.server")
    .withPort(ClickHouseProtocol.GRPC, 9100)
    .withDatabase("my_db")
    .build(),
  "select * from my_table",
  ClickHouseFormat.CSV,
  ClickHouseCompression.NONE,
  "/tmp/mytable.csv");

Note: compression is currently not supported very well, see ClickHouse/ClickHouse#28671 for details.

Now I’m still adding features and testing the client. If your work is somehow blocked by this, I can upload a version this weekend for you to play with. However, please be aware that the client is experimental, and you may have to upgrade ClickHouse server to a version containing changes from ClickHouse/ClickHouse#27064.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formats for Input and Output Data | ClickHouse Docs
ClickHouse can accept and return data in various formats. A format supported for input can be used to parse the data provided to...
Read more >
Settings | ClickHouse Docs
If column type is not nullable and this setting is disabled, then inserting ... If the number of rows to be read from...
Read more >
ClickHouse Tutorial | ClickHouse Docs
It is in CSV files in S3, and you can load the data from there. The following command inserts ~2,000,000 rows into your...
Read more >
S3 Table Functions | ClickHouse Docs
The s3 table function allows us to read and write files from and to S3 ... We can query s3 data as a...
Read more >
HTTP Interface | ClickHouse Docs
For successful requests that do not return a data table, an empty response body is returned. Compression​. You can use compression to reduce ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found