Search code examples
sqlprestotrino

How to combine multiple columns in one array in Presto


Suppose we have a table

|           Array1         |           Array2          |
| ------------------------ | ------------------------- |
|         0.99993938       |         1.88473736        |
|         4.66993938       |         10.7473736        |

How do combine these column values into one array.

Expected result:

|                  Array3                 | 
| --------------------------------------- |
|         [0.99993938, 1.88473736]        |
|         [4.66993938, 10.7473736]        |

I tried select concat(Array1, Array2) from table It does the job, but without the commas and it neglects the decimals.


Solution

  • To create an array you can do the following:

    select array[Column1, Column2]
    from table;