Skip to content

Instantly share code, notes, and snippets.

@matthew-brett
Created August 28, 2020 11:45
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 matthew-brett/89c2f72648622b387f12405d225cdcbb to your computer and use it in GitHub Desktop.
Save matthew-brett/89c2f72648622b387f12405d225cdcbb to your computer and use it in GitHub Desktop.
select distro_name, distro_version, libcv, (download_count / total * 100) as percent
from (
SELECT REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(LOWER(details.distro.name), " (gnu/)?linux", ""), "^red.?hat.*", "redhat"), "os x","macos") AS distro_name,
details.distro.version as distro_version,
details.distro.libc.version as libcv,
COUNT(*) AS download_count,
SUM(COUNT(*)) OVER () AS total
FROM `the-psf.pypi.downloads*`
WHERE
details.distro.name IS NOT NULL
-- Only query the last 30 days of history
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE(
'%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
GROUP BY
distro_name, distro_version, libcv
ORDER BY
download_count DESC
LIMIT 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment