Sql 使用Google BigQuery的逗号作为UNION ALL with IN子句

Sql 使用Google BigQuery的逗号作为UNION ALL with IN子句,sql,google-bigquery,Sql,Google Bigquery,我正在尝试执行以下查询: SELECT author, link_id, COUNT(link_id) as cnt FROM [fh-bigquery:reddit_comments.2015_12], [fh-bigquery:reddit_comments.2015_11] WHERE link_id IN ( SELECT posts.name FROM [fh-bigquery:reddit_posts.full_corpus_201512] AS posts

我正在尝试执行以下查询:

SELECT 
  author, link_id, COUNT(link_id) as cnt
FROM 
  [fh-bigquery:reddit_comments.2015_12],
  [fh-bigquery:reddit_comments.2015_11]
WHERE link_id IN (
  SELECT posts.name
  FROM [fh-bigquery:reddit_posts.full_corpus_201512] AS posts
  WHERE posts.subreddit = 'politics'
  ORDER BY posts.created_utc DESC
  LIMIT 300
)
GROUP BY author, link_id
ORDER BY author
我在执行时收到此错误消息:JOIN包括半JOIN和UNION ALL逗号,日期范围不能组合在单个SELECT语句中。要么将UNION ALL移动到内部查询,要么将JOIN移动到外部查询


删除一个注释表可以很好地工作,但是我似乎不知道BigQuery是如何工作的。我试图将联合移动到内部查询,但仍然出现相同的错误。

错误在于我误解了将联合全部移动到内部查询。为了解决这个错误,我不得不将这两个表放入一个基本的select*from。。。。工作查询如下:

SELECT 
  author, link_id, COUNT(link_id) as cnt
FROM (
  SELECT * 
  FROM
    [fh-bigquery:reddit_comments.2015_12],
    [fh-bigquery:reddit_comments.2015_11]
  )
WHERE link_id IN (
  SELECT posts.name
  FROM [fh-bigquery:reddit_posts.full_corpus_201512] AS posts
  WHERE posts.subreddit = 'politics'
  ORDER BY posts.created_utc DESC
  LIMIT 300
)
GROUP BY author, link_id
ORDER BY author