Bigquery UNNEST ARRAYS

时间:2019-07-03 11:58:28

标签: firebase google-bigquery

我想列出item_name,但contentType必须为“ POI”

[1] https://imgur.com/a/YEIx66C

select param.item_name from 'dataset', 
UNNEST(event_params) AS param
where event_name  = "select_content" AND param.value.string_value = "POI"

1 个答案:

答案 0 :(得分:1)

以下是用于BigQuery标准SQL

#standardSQL
SELECT 
  ( SELECT value.string_value
    FROM UNNEST(event_params) param
    WHERE key = 'item_name'
  ) AS item_name
FROM `project.dataset.table`
WHERE (
  SELECT COUNT(1) FROM UNNEST(event_params) param
  WHERE (key, value.string_value) = ('content_type', 'POI') OR key = 'item_name'
  ) = 2