simPod
simPod

Reputation: 13466

ClickHouse output by columns, not by rows (transpose without transpose actually?)

Is there a way to return data from ClickHouse not by rows but by columns?

So instead of result in a following form for columns a and b

a b
1 2
3 4
5 6

I'd get a transposed result

- - -
1 3 5
2 4 6

The point is I want to access data per column, eg. iterate over everything in column a.

I was checking available output formats - Arrow would do but it is not supported by my platform for now.

I'm looking for a most effective way. E.g. considered ClickHouse stores data in columns already, it does not have to process it into rows so I can transfer it back to columns using array functions afterwards. I'm not familiar with internals very much but I was wondering that I could somehow skip transposing rows if data are already in columns.

Upvotes: 0

Views: 1100

Answers (1)

Denny Crane
Denny Crane

Reputation: 13310

Obviously there is no easy way to do it. And a bigger issue that it's against the SQL conception.


You can use native protocol, although you will get columns in blocks by 65k rows.

col_a 65k values, col_b 65k values, col_a next 65k values, col_b next 65k values

Upvotes: 1

Related Questions