简体   繁体   English

Bigquery 列名不明确

[英]Bigquery Column name is ambiguous

in my table I have a column name "Status" and a RECORD type column name "Payment", which has another column name "Status" inside it.在我的表中,我有一个列名“Status”和一个RECORD类型的列名“Payment”,其中有另一个列名“Status”。 So I basically have 2 columns: "Status" and "Payment.Status".所以我基本上有 2 列:“状态”和“Payment.Status”。 When I want to UNNEST the STRUCT data("Payment" column) and use the data, I will get the error message Column name STATUS is ambiguous当我想UNNEST STRUCT数据(“付款”列)并使用数据时,我将收到错误消息Column name STATUS is ambiguous

How do I solve this problem?我该如何解决这个问题? Thanks in advance提前致谢

When you are trying to use 'STATUS', BigQuery does not know to which column you are referring to.当您尝试使用“STATUS”时,BigQuery 不知道您指的是哪一列。 You can overcome this with giving your UNNEST() an alias and using it to reference the specific column you are using.您可以通过给 UNNEST() 一个别名并使用它来引用您正在使用的特定列来克服这个问题。

Example:例子:

with example_data as (
    select true as status,
    [STRUCT( 123 as id, false as status)] as payment
)

select e.status, 
       p.id,
       p.status as payment_status
from example_data e, unnest(payment) as p 

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

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