没有连接的 BigQuery 查询在 "not in" 用法上给出连接错误
BigQuery query without join gives join error on "not in" usage
当我从子 select 执行 select 并最终想对结果执行 "not in" 时,BQ 查询给出以下错误:
Error: Join attribute is not defined: t1.customer_id
例如,当我用一个简单的 where t1.customer_id = 1
更改 "not in" 部分时,查询就会执行。
查询看起来不像是联接,但从错误来看,BigQuery 似乎认为是。
select t1.customer_id , GROUP_CONCAT(t1.id) from (
select customer.id as customer_id, id
from (TABLE_QUERY(redacted , 'table_id in ( "x_201502", "x_201503")'))
where created >= '2014-09-05 00:00:00'
and created < '2015-03-04 00:00:00'
group by customer_id, id
) t1
where t1.customer_id not in (
select customer.id as customer_id
from (TABLE_QUERY(redacted , 'table_id in ("y_201503")'))
where created >= '2015-03-03 18:55:59'
group by customer_id
)
group by t1.customer_id;
我最初尝试将 "not in" sub select 放在 subselect 中,但 BQ 也为该方法抛出了错误,因此我正在尝试这种构造。请注意,"not in" 部分在连接 2 个 subselect 时确实有效。
关于如何在这种特殊情况下完成 'not in' 检查有什么想法吗?
这是 BigQuery 中的 SQL 不兼容问题。作为解决方法,我认为仅使用 WHERE customer_id NOT IN (...)
应该可行。
当我从子 select 执行 select 并最终想对结果执行 "not in" 时,BQ 查询给出以下错误:
Error: Join attribute is not defined: t1.customer_id
例如,当我用一个简单的 where t1.customer_id = 1
更改 "not in" 部分时,查询就会执行。
查询看起来不像是联接,但从错误来看,BigQuery 似乎认为是。
select t1.customer_id , GROUP_CONCAT(t1.id) from (
select customer.id as customer_id, id
from (TABLE_QUERY(redacted , 'table_id in ( "x_201502", "x_201503")'))
where created >= '2014-09-05 00:00:00'
and created < '2015-03-04 00:00:00'
group by customer_id, id
) t1
where t1.customer_id not in (
select customer.id as customer_id
from (TABLE_QUERY(redacted , 'table_id in ("y_201503")'))
where created >= '2015-03-03 18:55:59'
group by customer_id
)
group by t1.customer_id;
我最初尝试将 "not in" sub select 放在 subselect 中,但 BQ 也为该方法抛出了错误,因此我正在尝试这种构造。请注意,"not in" 部分在连接 2 个 subselect 时确实有效。
关于如何在这种特殊情况下完成 'not in' 检查有什么想法吗?
这是 BigQuery 中的 SQL 不兼容问题。作为解决方法,我认为仅使用 WHERE customer_id NOT IN (...)
应该可行。