2

I have the following table in BigQuery:

A B
First [joe, becky, smith]
Second [joe, matthew]

Column B has type 'STRING'

I want to convert Column B into a big query array of ARRAY

I attempted to use JSON_EXTRACT_ARRAY but this does not work as the elements inside the arrays of B are not enclosed within double quotes (") (i.e. they are not of the form, ["joe", "becky", "smith"])

1 Answer 1

3

Consider below

select a, 
  array(select trim(val) from unnest(split(trim(b, '[]'))) val) b
from `project.dataset.table`           

when 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.