BigQuery QUALITY 子句可用吗?嵌套查询需要单个输出
BigQuery QUALITY clause available? Needing single output for nested query
QUALIFY 子句在 BQ 中可用吗?我正在尝试 运行 下面的查询以尝试提取单个最流行的 Route 值,以便我可以将它嵌套在另一个查询的 WHERE 子句中:
WITH table AS (
SELECT 'Point A' as Origin, 'Point B' as Destination, A as Route
FROM UNNEST(['Highway', 'Backroad', 'Highway', 'Highway', 'Backroad']) as A
)
SELECT
DISTINCT Route
FROM
table
WHERE
Origin = 'Point A' AND
Destination = 'Point B'
QUALIFY RANK() OVER (PARTITION BY Origin, Destination ORDER BY COUNT(*) DESC) = 1
What I have
What I want (most commonly used route)
并收到此一般性错误:
Error running query An internal error occurred and the request could
not be completed. This is usually caused by a transient issue.
Retrying the job with back-off as described in the BigQuery SLA should
solve the problem: https://cloud.google.com/bigquery/sla. If the error
continues to occur please contact support at
https://cloud.google.com/support. Error: 80038528
如果有更好的方法,请告诉我。我需要一种在评估最流行的值后提取单个行和列的有效方法,理想情况下没有嵌套查询。
考虑以下方法
SELECT
DISTINCT Route
FROM
table
WHERE
Origin = 'Point A' AND
Destination = 'Point B'
GROUP BY
Origin, Destination, Route
QUALIFY
RANK() OVER (PARTITION BY Origin, Destination ORDER BY COUNT(*) DESC) = 1
QUALIFY 子句在 BQ 中可用吗?我正在尝试 运行 下面的查询以尝试提取单个最流行的 Route 值,以便我可以将它嵌套在另一个查询的 WHERE 子句中:
WITH table AS (
SELECT 'Point A' as Origin, 'Point B' as Destination, A as Route
FROM UNNEST(['Highway', 'Backroad', 'Highway', 'Highway', 'Backroad']) as A
)
SELECT
DISTINCT Route
FROM
table
WHERE
Origin = 'Point A' AND
Destination = 'Point B'
QUALIFY RANK() OVER (PARTITION BY Origin, Destination ORDER BY COUNT(*) DESC) = 1
What I have
What I want (most commonly used route)
并收到此一般性错误:
Error running query An internal error occurred and the request could not be completed. This is usually caused by a transient issue. Retrying the job with back-off as described in the BigQuery SLA should solve the problem: https://cloud.google.com/bigquery/sla. If the error continues to occur please contact support at https://cloud.google.com/support. Error: 80038528
如果有更好的方法,请告诉我。我需要一种在评估最流行的值后提取单个行和列的有效方法,理想情况下没有嵌套查询。
考虑以下方法
SELECT
DISTINCT Route
FROM
table
WHERE
Origin = 'Point A' AND
Destination = 'Point B'
GROUP BY
Origin, Destination, Route
QUALIFY
RANK() OVER (PARTITION BY Origin, Destination ORDER BY COUNT(*) DESC) = 1