Filtering Arrays

Filtering arrays

Explore this snippet here.

Description

The ARRAY function in BigQuery will accept an entire subquery, which can be used to filter an array:

select array(
  select x
  from unnest((select [1, 2, 3, 4])) as x
  where x <= 3 -- Filter predicate
) as filtered