Skip to content

Instantly share code, notes, and snippets.

@markrittman
Created June 24, 2021 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markrittman/4b2f2423a904c9655de6b2c6d8528df2 to your computer and use it in GitHub Desktop.
Save markrittman/4b2f2423a904c9655de6b2c6d8528df2 to your computer and use it in GitHub Desktop.
List all datasets with partitioned tables, broken-down by partitioning type
SELECT
TABLE_SCHEMA,
count(distinct table_name) as table_count,
CASE
WHEN IS_SYSTEM_DEFINED = 'YES' THEN 'Ingestion-Time'
WHEN data_type = 'TIMESTAMP' THEN concat('Time-unit column')
WHEN data_type = 'INT64' THEN concat('Integer Range')
END
AS partitioning_type
FROM
region-eu.INFORMATION_SCHEMA.COLUMNS
WHERE
IS_PARTITIONING_COLUMN = 'YES'
GROUP BY
1,3
order by 3 desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment