George
George

Reputation: 4011

Clickhouse, column values to array

I want to make a query then turn the values for each of it's columns into arrays, I've tried finding a way to do this, but until now it has alluded me.

The query is a simple select:

SELECT a,b,c FROM X

Instead of the usual result of say (in the default format):

val_a_1, val_b_1, val_c_1

----------------

val_a_2, val_b_2, val_c_2

-----------------

val_a_3, val_b_3, val_c_3

I want to get an array for each columns, namely:

[val_a_1, val_a_2, val_a_3], [val_b_1, val_b_2, val_b_3] , [val_c_1, val_c_2, val_c_3]

Is this at all possible ?

Upvotes: 7

Views: 19922

Answers (1)

George
George

Reputation: 4011

Nevermind, this can easily be done with groupArray as:

SELECT groupArray(a), groupArray(b), groupArray(c) FROM X

It completely slipped my mind and google didn't help... leaving this here in case there's a better option or anyone stumbles upon it when searching.

Upvotes: 24

Related Questions