Reputation: 4972
I need to select specific rows from a table and transform the result into an array.
Let's say I have this query:
SELECT * FROM TEMP_TABLE WHERE ID > 1000
The result will be about 4 rows having the following structure:
I need to convert the result into an array of object.
I tried using:
select array_construct(*) from my_table;
But it transformed each row into an array with no keys like: [1, 'TEST', 2, 'DATA']
.
I am using a JavaScript procedure.
How to transform an sql select rows result into a variant on Snowflake?
Upvotes: 1
Views: 3084
Reputation: 4578
Use:
SELECT OBJECT_CONSTRUCT(*) FROM my_table;
rather than array_construct.
Upvotes: 2