I have an array of strings that are valid dates and I want to convert them into an array of dates.
Is there a more straightforward way to do the following in BigQuery?
SELECT CAST(['2014-01-01', '2015-01-01'] AS ARRAY<date>)
Currently, I'm having to do the following workaround:
SELECT ARRAY(select cast(_ as date) FROM UNNEST((select ["2014-01-01", "2015-01-01"])) _)
The input/output should be:
IN: ["2014-01-01", "2015-01-01"]
-->
OUT: [DATE "2014-01-01", DATE "2015-01-01"]
["2014-01-01"]into[DATE "2014-01-01"]select array_strings, array(select date(_) from t.array_strings _) array_dates from your_table as tobviously assuming those strings are dates, otherwise you do that extrasafe_cast(_ as date). Notesafe_castnot justcast