1

I have a key with a value that is an array in a BQ table, see below

"foo": [{"name":"bar","type":"FLOAT","value":"16.0"},{"name":"baz","type":"STRING","value":"F"}]

and I am trying to extract the value of foo.

This is what I am trying:

JSON_EXTRACT_ARRAY('$.f.foo') AS fooBarBaz

and then

ARRAY_AGG(f.foo) AS fooBarBaz

but this is not even returning null

What am I doing wrong?

1 Answer 1

1

Consider below "to extract the value of foo"

select json_extract_array('{' || col || '}', '$.foo') foo_items
from `project.dataset.table`  

if applied to sample data in your question - output is

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.