我有一个像这样的模式的BigQuery表(为了简洁起见列出了非常重要的字段):
id [STRING]
products [RECORD]
products.id [STRING]
我正在尝试执行查询并同时获取id和products.id:
SELECT
id as transaction_id,
products.id as product_id
FROM
`my-project.set.transactions_table`,
UNNEST(products) as products
并收到错误:Column name id is ambiguous at [2:3]
如何消除歧义?
答案 0 :(得分:4)
你的第一个id是含糊不清的。只需要添加表源
SELECT
transactions.id as transaction_id,
products.id as product_id
FROM
`my-project.set.transactions_table` as transactions,
UNNEST(products) as products