我当前的 sql 查询看起来像这样 -
select
id, event.messageid as test_message, event[safe_offset(1)]
from dataset.table
where event.reason.reasoncode='damaged1';
错误:-
无法访问 ARRAY 类型值的字段原因代码
> at[9.29]
查询在没有 where 子句的情况下工作正常,但当我添加它时,我收到错误。任何人都可以帮忙吗?
为了查询结构体中的字段,您必须首先取消数组的嵌套。 尝试下面的 SQL。
select id, event.messageid as test_message, event[safe_offset(1)]
from dataset.table, UNNEST(event) as event
where event.reason.reasoncode='damaged1';