我正在尝试在BigQuery中运行一个查询,它有两个子选择和一个连接,但我无法让它工作.我正在做的解决方法是自己运行子选择,然后将它们保存为表,然后使用连接执行另一个查询,但我认为我应该能够通过一个查询执行此操作.
我收到错误:
Table too large for JOIN. Consider using JOIN EACH. For more details, please see https://developers.google.com/bigquery/docs/query-reference#joins
但我已经在使用每个连接.我尝试过使用交叉连接并使用每个组,但这些给了我不同的错误.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
Run Code Online (Sandbox Code Playgroud)
你有一个GROUP BY
内心JOIN EACH
.GROUP BY
使用基数(不同值的数量)达到限制,并且最终分组不可并行化.这限制了BigQuery进行连接的能力.
如果更改GROUP BY
为GROUP EACH BY
,则很可能会有效.
(是的,我意识到这是令人不快和非标准的.BigQuery团队目前正在努力使这样的事情'正常工作'.)
归档时间: |
|
查看次数: |
2246 次 |
最近记录: |