2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

BigQueryでネストしたフィールドに検索かける方法

Last updated at Posted at 2022-08-23

FirebaseAnalyticsをエクスポートしたときなどに遭遇するネストしたフィールドを検索対象したい場合はSTRUCTを使って展開してあげればできます。

こういうやつです↓
スクリーンショット 2022-08-24 1.07.43.png

クエリ

SELECT * FROM (
  SELECT 
  (
    SELECT AS STRUCT
      ANY_VALUE(CASE WHEN key = 'ga_session_id' THEN value.int_value END) as ga_session_id,
      ANY_VALUE(CASE WHEN key = 'session_engaged' THEN value.string_value END) as session_engaged,
    FROM UNNEST(event_params)
  ).*
  FROM `dataset.events_20220822`
)
WHERE ga_session_id = 1661121678
AND session_engaged = '0';

結果

スクリーンショット 2022-08-24 1.12.09.png

これでevent_paramsやuser_propertiesを拡張しても複数の条件指定などができるかと思います。
それでは。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?