I am trying to declare a list of integers as a variable named list_of_ints. My code works, but it seems to be a bit of a workaround:
DECLARE list_of_ints ARRAY <INT64>;
set list_of_ints = (
SELECT ARRAY_AGG( DISTINCT some_ints)
FROM (SELECT * FROM UNNEST ([11,22,33]) as some_ints)
);
I was hoping for something along the lines of
DECLARE list_of_ints ARRAY <INT64>;
set list_of_ints = ARRAY([11,22,33]);
but it seems that this is improper syntax. Is there a way akin to the above attempt to declare an array as a variable in bigquery?
>Solution :
use below
DECLARE list_of_ints ARRAY <INT64>;
SET list_of_ints = [11,22,33];
OR
DECLARE list_of_ints ARRAY <INT64> DEFAULT [11,22,33]