Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test query for 'encoding -> format use' #1

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions sql/2021/media/media_formats.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE TEMPORARY FUNCTION fixFormat(format STRING, mimeType STRING)
RETURNS STRING
LANGUAGE js AS '''

if (mimeType === "image/avif") {
return "avif";
} else if (mimeType === "image/webp" || format==="webp") {
return "webp";
} else {
return format;
}

''';

SELECT
trueFormat,
COUNT(*) freq,
COUNT(DISTINCT NET.HOST(url)) as Hosts,
COUNT(DISTINCT pageid) as Pages
FROM (
SELECT
url,
pageid,
mimeType,
format,
fixFormat(format,mimeType) as trueFormat
FROM `httparchive.sample_data.summary_requests_*`
WHERE type="image" and respSize >0
)
GROUP BY trueFormat
ORDER BY freq DESC