使用JSON_EXTRACT_ARRAY展开BigQuery表-函数JSON_EXTRACT_ARRAY没有匹配的签名

s4n0splo  于 2023-03-09  发布在  其他
关注(0)|答案(1)|浏览(135)

我怎样才能最好地使用JSON_EXTRACT_ARRAY查询来展开下面的表?

我试过:

with raw as (
    select *
    from {{ source('hubspot','deal_pipelines') }} 
),
temp as (
select JSON_EXTRACT_ARRAY(stages,'$') as stages
from raw
)
select
    json_value(s,'$.label') as label
    ,json_value(s,'$.active') as active
from temp ,unnest(stages) as s

但我得到这个错误:

No matching signature for function JSON_EXTRACT_ARRAY for argument types: ARRAY<STRUCT<value STRUCT<probability FLOAT64, displayorder INT64, active BOOL, ...>>>, STRING. Supported signatures: JSON_EXTRACT_ARRAY(STRING, [STRING]); JSON_EXTRACT_ARRAY(JSON, [STRING]) at [18:8]

任何如何修复它的建议都将不胜感激。

0vvn1miw

0vvn1miw1#

stages的类型是ARRAY<STRUCT<value STRUCT<probability FLOAT64, displayorder INT64, active BOOL, ...>>>,而不是 JSON 字符串。

with raw as (
    select *
    from {{ source('hubspot','deal_pipelines') }} 
)
select
    s.value.label as label,
    s.value.active as active
from raw, unnest(stages) as s;

相关问题