Big Query - Group By Clause 不适用于 NEST()
Big Query - Group By Clause not working with NEST()
这是他们 public 测试数据的再现 -
SELECT corpus, NEST(word)
FROM [publicdata:samples.shakespeare]
GROUP BY corpus
LIMIT 1000
Row corpus f0_
1 1kinghenryiv brave
2 1kinghenryiv profession
3 1kinghenryiv treason
谁能告诉我我做错了什么?
没问题
每 https://cloud.google.com/bigquery/query-reference#aggfunctions
BigQuery automatically flattens query results, so if you use the NEST
function on the top level query, the results won't contain repeated
fields. Use the NEST function when using a subselect that produces
intermediate results for immediate use by the same query.
返回的行数证明了这一点(查询中为 1000 - 但结果为 41852,因为它被展平了:
您还可以运行在下方查询以查看 NEST() 是否确实有效:
SELECT corpus, COUNT(1) AS cnt
FROM (
SELECT corpus, NEST(word)
FROM [publicdata:samples.shakespeare]
GROUP BY corpus
LIMIT 1000
)
GROUP BY corpus
这是他们 public 测试数据的再现 -
SELECT corpus, NEST(word)
FROM [publicdata:samples.shakespeare]
GROUP BY corpus
LIMIT 1000
Row corpus f0_
1 1kinghenryiv brave
2 1kinghenryiv profession
3 1kinghenryiv treason
谁能告诉我我做错了什么?
没问题
每 https://cloud.google.com/bigquery/query-reference#aggfunctions
BigQuery automatically flattens query results, so if you use the NEST function on the top level query, the results won't contain repeated fields. Use the NEST function when using a subselect that produces intermediate results for immediate use by the same query.
返回的行数证明了这一点(查询中为 1000 - 但结果为 41852,因为它被展平了:
您还可以运行在下方查询以查看 NEST() 是否确实有效:
SELECT corpus, COUNT(1) AS cnt
FROM (
SELECT corpus, NEST(word)
FROM [publicdata:samples.shakespeare]
GROUP BY corpus
LIMIT 1000
)
GROUP BY corpus