小编Dav*_*djb的帖子

Google BigQuery要求加入,但我已经在使用它了

我正在尝试在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 …
Run Code Online (Sandbox Code Playgroud)

google-bigquery

6
推荐指数
1
解决办法
2246
查看次数

BigQuery:如何避免"在查询执行期间超出资源".错误

我想知道如何避免"执行期间超出资源"错误.关于这个的大多数其他问题涉及JOIN EACH或GROUP EACH BY,但我已经没有使用它们了.如果我在日期或ABS(HASH(userId))上包含WHERE子句,那么查询可以工作,但我想让整个数据集可用,然后我将在Tableau中进一步过滤它.

如果我删除t4查询有效,但我想要最后一列,并且我希望在event_parameters字段中创建更多列以供以后查询.

工作ID是rhi-localytics-db:job_6MaesvuMK6mP6irmAnrcM9R3cx8如果有帮助,谢谢.

SELECT
    t1.userId as userId,
    t1.event_time AS event_time,
    t1.Diamond_Balance as Diamond_Balance,
    t2.Diamond_Change as Diamond_Change,
    t3.Gold_Balance as Gold_Balance,
    t4.Gold_Change as Gold_Change
FROM (
    SELECT
        userId,
        event_time,
        INTEGER(event_parameters.Value) AS Diamond_Balance,
    FROM
        FLATTEN([game_data], event_parameters)
    WHERE
        event_name LIKE 'Currency'
        AND event_parameters.Name = 'Diamond_Balance'
        -- and date(event_time) > '2015-09-11'
        -- AND ABS(HASH(userId) % 5)  = 0
    GROUP BY
        userId,
        event_time,
        Diamond_Balance ) AS t1
INNER JOIN (
    SELECT
        userId,
        event_time,
        INTEGER(event_parameters.Value) AS Diamond_Change,
    FROM
        FLATTEN([game_data], event_parameters)
    WHERE
        event_name LIKE 'Currency' …
Run Code Online (Sandbox Code Playgroud)

sql google-bigquery

3
推荐指数
1
解决办法
9856
查看次数

标签 统计

google-bigquery ×2

sql ×1