[英]Google BigQuery GROUP BY timeout
我正在尝试通过 Google BigQuery 从 github 存档中查询合作者登录名、存储库语言和名称。 如果我排除 GROUP BY,则以下查询工作正常,但使用 GROUP BY 查询将永远持续,直到我从 google bigquery 获得超时。 由于 Google BigQuery 没有 DISTINCT,我尝试使用 GROUP BY 作为 DISTINCT,这样我就不会得到重复的行。 这是我正在使用的查询:
SELECT
a1.actor_attributes_login,
a2.actor_attributes_login,
a1.repository_language,
a1.repository_name,
FROM
[githubarchive:year.2014] AS a1
LEFT JOIN
[githubarchive:year.2014] AS a2
ON
a1.repository_name = a2.repository_name
WHERE
a1.actor_attributes_login != a2.actor_attributes_login
AND a1.actor_attributes_location = "California"
AND (a1.repository_language = "Java"
OR a1.repository_language = "Python")
GROUP BY
a1.actor_attributes_login,
a2.actor_attributes_login,
a1.repository_language,
a1.repository_name
LIMIT
10000
嗯。 您可以尝试在加入之前删除重复项:
SELECT a1.actor_attributes_login, a2.actor_attributes_login,
a1.repository_language, a1.repository_name
FROM (SELECT a.actor_attributes_login, a.repository_language, a1.repository_name
FROM githubarchive:year.2014] a
WHERE a.actor_attributes_location = 'California AND
a.repository_language IN ('Java', 'Python')
GROUP BY a.actor_attributes_login, a.repository_language, a.repository_name
) a1 LEFT JOIN
(SELECT a1.actor_attributes_login, a1.repository_language, a1.repository_name
FROM githubarchive:year.2014] a1
GROUP BY a1.actor_attributes_login, a1.repository_language, a1.repository_name
) a2
ON a1.repository_name = a2.repository_name
WHERE a1.actor_attributes_login <> a2.actor_attributes_login
LIMIT 10000;
如果您消除子查询中的重复项,我认为您不需要外部GROUP BY
。
此外,如果您使用LIMIT
,您应该有一个ORDER BY
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.