【发布时间】:2015-02-24 19:01:20
【问题描述】:
我正在尝试在 BigQuery 中运行一个查询,该查询有两个子选择和一个连接,但我无法让它工作。我正在做的一种解决方法是自己运行子选择,然后将它们保存为表,然后使用连接执行另一个查询,但我认为我应该能够使用一个查询来执行此操作。
我收到了错误:
Table too large for JOIN. Consider using JOIN EACH. For more details, please see https://developers.google.com/bigquery/docs/query-reference#joins
但我已经在使用每个连接。我尝试过使用交叉连接并使用 group by each 但这些给了我不同的错误。 Stack Overflow 上关于这个主题的其他问题没有帮助,一个说这是 BigQuery 中的一个错误,另一个是有人使用“cross join each”...
下面是我的sql,如果有错误请见谅,但我认为它应该可以工作:
select
t1.device_uuid,
t1.session_uuid,
t1.nth,
t1.Diamonds_Launch,
t2.Diamonds_Close
from (
select
device_uuid,
session_uuid,
nth,
sum(cast([project_id].[table_id].attributes.Value as integer)) as Diamonds_Launch
from [project_id].[table_id]
where name = 'App Launch'
and attributes.Name = 'Inventory - Diamonds'
group by device_uuid, session_uuid, nth
) as t1
join each (
select
device_uuid,
session_uuid,
nth,
sum(cast([project_id].[table_id].attributes.Value as integer)) as Diamonds_Close
from [project_id].[table_id]
where name = 'App Close'
and attributes.Name = 'Inventory - Diamonds'
group by device_uuid, session_uuid, nth
) as t2
on t1.device_uuid = t2.device_uuid
and t1.session_uuid = t2.session_uuid
【问题讨论】:
标签: google-bigquery