Search code examples
clickhouse

Convert Tuple to Array in ClickHouse


How do I convert a tuple to an array type?

I have

('a', 'b')

And want to convert to an array type

['a', 'b']

The primary reason for the conversion is to use the arrayMap(~) function to transform the elements. The tuple type doesn't seem to have an equivalent function.

Thanks


Solution

  • You can do something like this:

    :) select array(untuple(('a', 'b'))) AS out
    
    ┌─out───────┐
    │ ['a','b'] │
    └───────────┘
    

    Thanks