Created
January 18, 2025 12:50
-
-
Save Liscor/adce63f6404663d961b37a3445ff4b37 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- Activate Change History for a BigQuery table | |
ALTER TABLE IF EXISTS | |
`XXX.analytics_XXX.events_20250113` | |
SET | |
OPTIONS(enable_change_history=TRUE) | |
-- Query Changes for a day maximum | |
select | |
parse_date('%Y%m%d',event_date) as event_date | |
,platform | |
,_change_type | |
,count(*) as events | |
FROM | |
CHANGES(TABLE `XXX.analytics_XXX.events_20250113`, TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 5 Day), TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 4 Day)) | |
group by | |
all | |
order by | |
3,2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment