Vasil Mitov
Vasil Mitov

Reputation: 67

Google BigQuery standart SQL insert nested row which has nested rows

I'm trying to figure out how to run an INSERT (i guess update?) query to insert into rows which are nested, but latter rows also have a nested schema in themselves.

For instance i have something like enter image description here

What would a general template query look like?

I know that for the lines it would look something like enter image description here

Upvotes: 1

Views: 136

Answers (1)

Vasil Mitov
Vasil Mitov

Reputation: 67

Managed to solve it with:

UPDATE test 
SET lines=ARRAY(
SELECT line FROM UNNEST(lines) AS line
UNION ALL
SELECT (
'::someValue::,
ARRAY<STRUCT<STRING,STRING,FLOAT64>>[('someId','someString',1.0)]
)
WHERE id='someId'

Upvotes: 1

Related Questions