Skip to content
Advertisement

How to check if a value exists in an array type column using SQL?

I am having a bigquery table with many columns including one array type column of zero or many integers.

For instance:

Using BigQuery SQL, I want to generate another column exists if any value of tuple (3, 10) is included in some_numbers arrays.

My desired output:

How can I do this?

Advertisement

Answer

Consider below approach

when applied to sample data in your question – output is

enter image description here

Note: I used format('%T', some_numbers) just for the sake of formatting output of array – but you might use just some_numbers instead

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement