Sql Google BigQuery组超时
我试图通过Google BigQuery从github归档中查询协作者登录名、存储库语言和名称。如果我排除GROUP BY,下面的查询工作正常,但是对于GROUP BY,查询将永远继续,直到我从google bigquery获得超时。由于GoogleBigQuery没有DISTINCT,所以我尝试使用GroupBy作为DISTINCT,这样我就不会得到重复的行。以下是我使用的查询:Sql Google BigQuery组超时,sql,google-bigquery,Sql,Google Bigquery,我试图通过Google BigQuery从github归档中查询协作者登录名、存储库语言和名称。如果我排除GROUP BY,下面的查询工作正常,但是对于GROUP BY,查询将永远继续,直到我从google bigquery获得超时。由于GoogleBigQuery没有DISTINCT,所以我尝试使用GroupBy作为DISTINCT,这样我就不会得到重复的行。以下是我使用的查询: SELECT a1.actor_attributes_login, a2.actor_attrib
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;
如果消除子查询中的重复项,我认为您不需要外部分组
此外,如果您使用的是LIMIT,您应该有一个订购人。Ah legend!我不得不在第一个内部选择中更改名称a1,因为它在这一个中用于两个表,并且它被拒绝,因为它有歧义,但除此之外,它工作得很好。谢谢