简体   繁体   English

当我尝试取消嵌套数组字段时,BigQuery中出现“列名ID不明确”错误

[英]“Column name id is ambiguous” error in BigQuery when I'm trying to unnest an array field

I have a BigQuery table with schema like this (noly important fields are listed for brevity): 我有一个具有这样的架构的BigQuery表(为简洁起见,列出了重要的字段):

id [STRING]
products [RECORD]
products.id [STRING]

I'm trying to perform a query and get both id and products.id like this: 我正在尝试执行查询,并获得id和products.id,如下所示:

SELECT 
  id as transaction_id,
  products.id as product_id
FROM 
  `my-project.set.transactions_table`,
  UNNEST(products) as products

and get an error: Column name id is ambiguous at [2:3] 并得到一个错误: Column name id is ambiguous at [2:3]

How do I remove ambiguity here? 如何在这里消除歧义?

Your first id is the ambiguous one. 您的第一个id是模棱两可的。 Just need to add the table source 只需要添加表源

SELECT 
  transactions.id as transaction_id,
  products.id as product_id
FROM 
  `my-project.set.transactions_table` as transactions,
  UNNEST(products) as products

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM