我在BigQuery中加入时遇到错误

时间:2018-05-24 13:38:00

标签: sql google-bigquery

我正在尝试将一个表中的数据与其他三个表中的相应匹配字段连接起来。

当我有一个JOIN它工作正常,但添加其他我得到以下错误消息:

  

字段   'dtftv2_sprt_p_match_table_advertisers_166401._PARTITION_LOAD_TIME'   在JOIN的任何一侧都找不到

此处我的查询:

SELECT
dtftv2_sprt.sprt_all_clicks.Date as Date,
dtftv2_sprt.p_match_table_advertisers_166401.Advertiser as Advertiser,
dtftv2_sprt.p_match_table_campaigns_166401.Campaigns as Campaign,
dtftv2_sprt.p_match_table_placements_166401.Placements as Placement,
dtftv2_sprt.sprt_all_clicks.Clicks as Clicks

FROM [dtftv2_sprt.sprt_all_clicks]

INNER JOIN [dtftv2_sprt.p_match_table_advertisers_166401] ON 
dtftv2_sprt.sprt_all_clicks.Advertiser_ID = 
dtftv2_sprt.p_match_table_advertisers_166401.Advertiser_ID

INNER JOIN [dtftv2_sprt.p_match_table_campaigns_166401] ON 
dtftv2_sprt.sprt_all_clicks.Campaign_ID = 
dtftv2_sprt.p_match_table_campaigns_166401.Campaign_ID

INNER JOIN [dtftv2_sprt.p_match_table_placements_166401] ON 
dtftv2_sprt.sprt_all_clicks.Placement_ID = 
dtftv2_sprt.p_match_table_placements_166401.Placement_ID

GROUP BY
Date,
Advertiser,
Campaign,
Placement,
Clicks

我没有在任何地方链接_PARTITION_LOAD_TIME,为什么它会大惊小怪呢? INNER加入正确的使用?

2 个答案:

答案 0 :(得分:2)

试图将问题限制为连接:也许它与创建/使用的表的分区有关。我不知道系统是否可以要求在执行查询时有关使用哪个分区的信息。但是,我之前没有看到像这样使用的分区。

#standardSQL
SELECT AC.Date as Date,
      TA.Advertiser as Advertiser,
      TC.Campaigns as Campaign,
      TP.Placements as Placement,
      AC.Clicks as Clicks
FROM `dtftv2_sprt.sprt_all_clicks` AC
INNER JOIN `dtftv2_sprt.p_match_table_advertisers_166401` TA 
   ON AC.Advertiser_ID = TA.Advertiser_ID
INNER JOIN `dtftv2_sprt.p_match_table_campaigns_166401` TC 
   ON AC.Campaign_ID = TC.Campaign_ID
INNER JOIN `dtftv2_sprt.p_match_table_placements_166401` TP 
   ON AC.Placement_ID = TP.Placement_ID
GROUP BY Date,
         Advertiser,
         Campaign,
         Placement,
         Clicks

并且可能基于"Error: Field '[REDACTED].field_id' not found on either side of the JOIN", Google BigQuery

返回刻度而不是[]

答案 1 :(得分:0)

以下是Legacy SQL版本的参考目的:

SELECT AC.Date as Date, 
       TA.Advertiser as Advertiser,
       TC.Campaign as Campaign,
       TP.Placement as Placement,
       AC.Clicks as Clicks

FROM [dtftv2_sprt.sprt_all_clicks] AC

INNER JOIN [dtftv2_sprt.p_match_table_advertisers_166401] TA 
   ON AC.Advertiser_ID = TA.Advertiser_ID

INNER JOIN [dtftv2_sprt.p_match_table_campaigns_166401] TC 
   ON AC.Campaign_ID = TC.Campaign_ID

INNER JOIN [dtftv2_sprt.p_match_table_placements_166401] TP 
   ON AC.Placement_ID = TP.Placement_ID

GROUP BY Date,
         Advertiser,
         Campaign,
         Placement,
         Clicks