Created
February 5, 2021 04:21
-
-
Save 1987yama3/fa61c3c430383a7aa94dbac64ef7f14c to your computer and use it in GitHub Desktop.
BigQueryのGA4データをサンプリングしたテーブルを生成する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- プロジェクト名、データセット名は自身のものに置き換えること。 | |
SELECT | |
* | |
FROM | |
`プロジェクト名.データセット名.events_20210201` | |
WHERE | |
TRUE | |
AND MOD(ABS(FARM_FINGERPRINT(user_pseudo_id)), 10) = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- プロジェクト名、データセット名は自身のものに置き換えること。 | |
-- サンプリングレートの設定は、各自変更したものを使うこと。 | |
SELECT | |
* | |
FROM | |
`プロジェクト名.データセット名.events_*` | |
WHERE | |
TRUE | |
AND MOD(ABS(FARM_FINGERPRINT(user_pseudo_id)), 10) = 0 | |
AND _TABLE_SUFFIX = FORMAT_DATE("%Y%m%d", DATE_SUB(@run_date, INTERVAL 1 DAY)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events_{run_time-24h|"%Y%m%d"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment