Last active
August 26, 2022 09:39
-
-
Save lacerogers20/aed630cbbb1a8cd11de4efa27155243f to your computer and use it in GitHub Desktop.
This will use "create table" and generate a new table with clustering and partitioning
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
CREATE TABLE | |
`testing.insert` (date DATE OPTIONS( description='date' ), | |
unique_visits INT64 OPTIONS( description='counts' )) | |
PARTITION BY | |
date | |
CLUSTER BY | |
unique_visits OPTIONS ( description="A table with a date partition", | |
labels=[("testing", | |
"data_is_great")], | |
expiration_timestamp=TIMESTAMP "2023-01-01 00:00:00 UTC" | |
) AS ( | |
SELECT | |
DATE(TIMESTAMP_SECONDS( visitStartTime)) AS date, | |
COUNT(DISTINCT(visitid)) AS unique_visits | |
FROM | |
`bigquery-public-data.google_analytics_sample.ga_sessions_*` | |
WHERE | |
_table_suffix = '20170801' | |
GROUP BY | |
1); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment