!set outputformat table with titles as ( select # "/api/rest_v1/page/pdf/".length + 1 substr(uri_path, 23) as title from wmf.webrequest where year = M and month = N and day = O and hour >= P and hour < Q and webrequest_source = 'text' and uri_path like "/api/rest_v1/page/pdf%" and agent_type = "user" ), grouped_titles as ( select title, count(*) as n from titles group by title order by n desc # We limit here in order to minimize the performance impact of running the reflect UDF below. limit 10 ) select reflect("java.net.URLDecoder", "decode", title, "utf-8") as title, n from grouped_titles ;