Skip to content
Advertisement

BigQuery – JOIN on two tables using string and array

We have two tables in BigQuery like below:

Table A

Table B (Static)

Expected table

In the above tables, the Answer field is of string type and Interests is of array type.

Pointers:

  1. One user can have one or more interests.
  2. One or more interests can belong to one segment.
  3. A user will be assigned to a segment only when all of his interests are matched.

Any inputs/thoughts in the right direction would be greatly appreciated.

Advertisement

Answer

Below is for BigQuery Standard SQL

if to apply to sample data from your question – output is

enter image description here

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