-
-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathcontent_encoding.sql
More file actions
31 lines (30 loc) · 707 Bytes
/
content_encoding.sql
File metadata and controls
31 lines (30 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- Temporary function to extract content-encoding
CREATE TEMPORARY FUNCTION GET_CONTENT_ENCODING(response_headers ARRAY<STRUCT<name STRING, value STRING>>)
RETURNS STRING AS (
(
SELECT
value
FROM
UNNEST(response_headers) AS header
WHERE
LOWER(header.name) = 'content-encoding'
LIMIT 1 -- noqa: AM09
)
);
SELECT
date,
client,
GET_CONTENT_ENCODING(response_headers) AS content_encoding,
COUNT(0) AS freq,
SUM(COUNT(0)) OVER (PARTITION BY client) AS total,
COUNT(0) / SUM(COUNT(0)) OVER (PARTITION BY client) AS pct
FROM
`httparchive.all.requests`
WHERE
date = '2024-06-01' AND
is_main_document
GROUP BY
client,
content_encoding
ORDER BY
pct DESC