Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

google bigquery - Optimizing SQL Cross Join that checks if any array value in other column

Let's say I have a table events with structure:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Few quick options for BigQuery Standard SQL

Option 1

select id
from `project.dataset.events`
where exists (
  select 1
  from `project.dataset.values_of_interest` 
  where value in unnest(value_array)
)     

Option 2

select id
from `project.dataset.events` t
where (
  select count(1)
  from t.value_array as value
  join `project.dataset.values_of_interest`
  using(value)
) > 0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...